diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py
index 63fd91182..7b6203684 100644
--- a/Lib/fontTools/feaLib/builder.py
+++ b/Lib/fontTools/feaLib/builder.py
@@ -555,10 +555,10 @@ class Builder(object):
alts.add(to_glyph)
return
if prefix or suffix:
+ chain = self.get_lookup_(location, ChainContextSubstBuilder)
sub = self.get_chained_lookup_(location, SingleSubstBuilder)
sub.mapping.update(mapping)
- lookup = self.get_lookup_(location, ChainContextSubstBuilder)
- lookup.substitutions.append(
+ chain.substitutions.append(
(prefix, [mapping.keys()], suffix, [sub]))
return
lookup = self.get_lookup_(location, SingleSubstBuilder)
diff --git a/Lib/fontTools/feaLib/testdata/GSUB_6.ttx b/Lib/fontTools/feaLib/testdata/GSUB_6.ttx
index 8e5173e2b..80f3bf03e 100644
--- a/Lib/fontTools/feaLib/testdata/GSUB_6.ttx
+++ b/Lib/fontTools/feaLib/testdata/GSUB_6.ttx
@@ -23,7 +23,7 @@
-
+
@@ -34,14 +34,6 @@
-
-
-
-
-
-
-
-
@@ -62,7 +54,7 @@
-
+
@@ -88,6 +80,14 @@
+
+
+
+
+
+
+
+
diff --git a/Lib/fontTools/feaLib/testdata/bug463.ttx b/Lib/fontTools/feaLib/testdata/bug463.ttx
index 7b025e7d4..0231fa670 100644
--- a/Lib/fontTools/feaLib/testdata/bug463.ttx
+++ b/Lib/fontTools/feaLib/testdata/bug463.ttx
@@ -1,5 +1,5 @@
-
+
@@ -23,22 +23,13 @@
-
+
-
-
-
-
-
-
-
-
-
@@ -65,7 +56,7 @@
-
+
@@ -95,6 +86,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/Lib/fontTools/feaLib/testdata/feature_aalt.ttx b/Lib/fontTools/feaLib/testdata/feature_aalt.ttx
index 01709fe52..f1db11f65 100644
--- a/Lib/fontTools/feaLib/testdata/feature_aalt.ttx
+++ b/Lib/fontTools/feaLib/testdata/feature_aalt.ttx
@@ -48,7 +48,7 @@
-
+
@@ -100,15 +100,6 @@
-
-
-
-
-
-
-
-
-
@@ -135,7 +126,7 @@
-
+
@@ -165,6 +156,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/Lib/fontTools/feaLib/testdata/spec5fi2.ttx b/Lib/fontTools/feaLib/testdata/spec5fi2.ttx
index 0bce0907a..45d70cd2d 100644
--- a/Lib/fontTools/feaLib/testdata/spec5fi2.ttx
+++ b/Lib/fontTools/feaLib/testdata/spec5fi2.ttx
@@ -1,5 +1,5 @@
-
+
@@ -23,21 +23,13 @@
-
+
-
-
-
-
-
-
-
-
@@ -56,10 +48,18 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/Lib/fontTools/feaLib/testdata/spec5fi3.ttx b/Lib/fontTools/feaLib/testdata/spec5fi3.ttx
index d4e33b78a..cba6725aa 100644
--- a/Lib/fontTools/feaLib/testdata/spec5fi3.ttx
+++ b/Lib/fontTools/feaLib/testdata/spec5fi3.ttx
@@ -1,5 +1,5 @@
-
+
@@ -23,46 +23,13 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -129,10 +96,43 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Lib/fontTools/feaLib/testdata/spec8a.ttx b/Lib/fontTools/feaLib/testdata/spec8a.ttx
index 579ca1400..14d085d2e 100644
--- a/Lib/fontTools/feaLib/testdata/spec8a.ttx
+++ b/Lib/fontTools/feaLib/testdata/spec8a.ttx
@@ -70,7 +70,7 @@
-
+
@@ -151,16 +151,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -182,10 +172,20 @@
-
+
+
+
+
+
+
+
+
+
+
+