diff --git a/packages/optimizer/lib/transformers/AutoExtensionImporter.js b/packages/optimizer/lib/transformers/AutoExtensionImporter.js index 55524314c..02bad8b13 100644 --- a/packages/optimizer/lib/transformers/AutoExtensionImporter.js +++ b/packages/optimizer/lib/transformers/AutoExtensionImporter.js @@ -176,7 +176,7 @@ class AutoExtensionImporter { } // We use this for adding new import elements to the header - const referenceNode = findMetaViewport(head); + let referenceNode = findMetaViewport(head); // Use cdn.ampproject.org as default, RewriteUrlTransformer will change this in case of self-hosting const host = AMP_CACHE_HOST; @@ -201,6 +201,7 @@ class AutoExtensionImporter { extensionImportAttribs[extension.type] = extensionName; const extensionImport = createElement('script', extensionImportAttribs); insertAfter(head, extensionImport, referenceNode); + referenceNode = extensionImport; } } diff --git a/packages/optimizer/spec/transformers/valid/AutoExtensionImporter/amp-access-laterpay/expected_output.html b/packages/optimizer/spec/transformers/valid/AutoExtensionImporter/amp-access-laterpay/expected_output.html index 99045ab49..d0ec2cb2a 100644 --- a/packages/optimizer/spec/transformers/valid/AutoExtensionImporter/amp-access-laterpay/expected_output.html +++ b/packages/optimizer/spec/transformers/valid/AutoExtensionImporter/amp-access-laterpay/expected_output.html @@ -5,9 +5,9 @@ amp-access-laterpay - - + + - - + + + - - - - - - - - - + + + + + + + + + + diff --git a/packages/optimizer/spec/transformers/valid/AutoExtensionImporter/ignores-existing-extensions/expected_output.html b/packages/optimizer/spec/transformers/valid/AutoExtensionImporter/ignores-existing-extensions/expected_output.html index fdbd86ca3..2bb01c5a7 100644 --- a/packages/optimizer/spec/transformers/valid/AutoExtensionImporter/ignores-existing-extensions/expected_output.html +++ b/packages/optimizer/spec/transformers/valid/AutoExtensionImporter/ignores-existing-extensions/expected_output.html @@ -5,8 +5,8 @@ My AMP Page - +