@ampproject/toolbox-optimizer
Advanced tools
Comparing version 2.8.1-canary.0 to 2.8.1-canary.1
@@ -48,6 +48,6 @@ /** | ||
'AmpBoilerplateTransformer', | ||
'RewriteAmpUrls', | ||
// Adds amp-onerror to disable boilerplate early | ||
// needs to run after ServerSideRendering | ||
// needs to run after BoilerplateTransformer and rewrite AMP URLs | ||
'AmpBoilerplateErrorHandler', | ||
'RewriteAmpUrls', | ||
'GoogleFontsPreconnect', | ||
@@ -93,6 +93,6 @@ 'PruneDuplicateResourceHints', | ||
'AmpBoilerplateTransformer', | ||
'RewriteAmpUrls', | ||
// Adds amp-onerror to disable boilerplate early | ||
// needs to run after ServerSideRendering | ||
// needs to run after BoilerplateTransformer and rewrite AMP URLs | ||
'AmpBoilerplateErrorHandler', | ||
'RewriteAmpUrls', | ||
'GoogleFontsPreconnect', | ||
@@ -99,0 +99,0 @@ 'PruneDuplicateResourceHints', |
@@ -19,3 +19,14 @@ /** | ||
const {appendChild, createElement, firstChildByTag, insertText} = require('../NodeUtils'); | ||
const ERROR_HANDLER_TRANSFORMED = | ||
/** | ||
* Error handler script to be added to the document's <head> for AMP pages not using ES modules. | ||
*/ | ||
const ERROR_HANDLER_NOMODULE = | ||
'document.querySelector("script[src*=\'/v0.js\']").onerror=function(){' + | ||
"document.querySelector('style[amp-boilerplate]').textContent=''}"; | ||
/** | ||
* Error handler script to be added to the document's <head> for AMP pages using ES modules. | ||
*/ | ||
const ERROR_HANDLER_MODULE = | ||
'[].slice.call(document.querySelectorAll(' + | ||
@@ -35,3 +46,3 @@ "\"script[src*='/v0.js'],script[src*='/v0.mjs']\")).forEach(" + | ||
class AmpBoilerplateErrorHandler { | ||
transform(root) { | ||
transform(root, params) { | ||
const html = firstChildByTag(root, 'html'); | ||
@@ -53,3 +64,7 @@ if (!html) { | ||
const errorHandler = createElement('script', {'amp-onerror': ''}); | ||
insertText(errorHandler, ERROR_HANDLER_TRANSFORMED); | ||
if (params.esmModuleEnabled) { | ||
insertText(errorHandler, ERROR_HANDLER_MODULE); | ||
} else { | ||
insertText(errorHandler, ERROR_HANDLER_NOMODULE); | ||
} | ||
@@ -56,0 +71,0 @@ appendChild(head, errorHandler); |
@@ -39,2 +39,3 @@ /** | ||
'flex-item', | ||
'fluid', | ||
'intrinsic', | ||
@@ -83,2 +84,6 @@ ]; | ||
break; | ||
case 'fluid': | ||
styles = 'width:100%;height:0;'; | ||
addClass(node, 'i-amphtml-layout-awaiting-size'); | ||
break; | ||
case 'flex-item': | ||
@@ -85,0 +90,0 @@ if (width.isSet) { |
@@ -75,2 +75,3 @@ /** | ||
const esm = this.esmModulesEnabled || params.esmModulesEnabled; | ||
params.esmModulesEnabled = esm; | ||
const preloads = []; | ||
@@ -77,0 +78,0 @@ |
{ | ||
"name": "@ampproject/toolbox-optimizer", | ||
"version": "2.8.1-canary.0", | ||
"version": "2.8.1-canary.1", | ||
"description": "Server-side rendering for AMPs.", | ||
@@ -51,3 +51,3 @@ "main": "index.js", | ||
"homepage": "https://github.com/ampproject/amp-toolbox/tree/main/packages/optimizer", | ||
"gitHead": "5d38b310f5c3c467220b03e3217ee8dc6f5e37d9" | ||
"gitHead": "6031314b0367d685f9b8c0769937bfb9b978b12c" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
250018
5616