diff --git a/extensions/amp-date-display/0.1/test/validator-amp-date-display.out b/extensions/amp-date-display/0.1/test/validator-amp-date-display.out index 1ee8ec400073..c3f49a4f10ec 100644 --- a/extensions/amp-date-display/0.1/test/validator-amp-date-display.out +++ b/extensions/amp-date-display/0.1/test/validator-amp-date-display.out @@ -188,4 +188,4 @@ amp-date-display/0.1/test/validator-amp-date-display.html:169:2 The attribute 'd | | | -| \ No newline at end of file +| diff --git a/extensions/amp-script/0.1/test/validator-amp-script.out b/extensions/amp-script/0.1/test/validator-amp-script.out index 007d8d99ae1a..de4769bf4791 100644 --- a/extensions/amp-script/0.1/test/validator-amp-script.out +++ b/extensions/amp-script/0.1/test/validator-amp-script.out @@ -112,4 +112,4 @@ amp-script/0.1/test/validator-amp-script.html:84:2 Custom JavaScript is not allo amp-script/0.1/test/validator-amp-script.html:89:2 Custom JavaScript is not allowed. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#html-tags) [CUSTOM_JAVASCRIPT_DISALLOWED] | document.body.textContent = "Hello World!"; | -| \ No newline at end of file +| diff --git a/validator/engine/validator.js b/validator/engine/validator.js index 87f89265a7b3..c5586ac78aa3 100644 --- a/validator/engine/validator.js +++ b/validator/engine/validator.js @@ -1518,7 +1518,7 @@ class TagStack { } /** - * Records that tag currently on the stack is using ampdevmode. + * Records that tag currently on the stack is using data-ampdevmode. */ setDevMode() { this.back_().devMode = true; @@ -2741,11 +2741,11 @@ class Context { } /** - * Returns true iff "ampdevmode" is a type identifier in this document. + * Returns true iff "data-ampdevmode" is a type identifier in this document. * @return {boolean} */ isDevMode() { - return this.typeIdentifiers_.includes('ampdevmode'); + return this.typeIdentifiers_.includes('data-ampdevmode'); } /** @@ -4252,19 +4252,19 @@ function validateAttrDeclaration( /** * Returns true if errors reported on this tag should be suppressed, due to - * ampdevmode annotations. + * data-ampdevmode annotations. * @param {!amp.htmlparser.ParsedHtmlTag} encounteredTag * @param {!Context} context * @return {boolean} */ function ShouldSuppressDevModeErrors(encounteredTag, context) { if (!context.isDevMode()) return false; - // Cannot suppress errors on HTML tag. The "ampdevmode" here is a + // Cannot suppress errors on HTML tag. The "data-ampdevmode" here is a // type identifier. Suppressing errors here would suppress all errors since // HTML is the root of the document. if (encounteredTag.upperName() === 'HTML') return false; for (const attr of encounteredTag.attrs()) { - if (attr.name === 'ampdevmode') return true; + if (attr.name === 'data-ampdevmode') return true; } return context.getTagStack().isDevMode(); } @@ -4979,7 +4979,7 @@ class ParsedValidatorRules { this.typeIdentifiers_['amp4email'] = 0; this.typeIdentifiers_['actions'] = 0; this.typeIdentifiers_['transformed'] = 0; - this.typeIdentifiers_['ampdevmode'] = 0; + this.typeIdentifiers_['data-ampdevmode'] = 0; /** * @type {function(!amp.validator.TagSpec) : boolean} @@ -5191,7 +5191,7 @@ class ParsedValidatorRules { // mandatory unlike other type identifiers. if (typeIdentifier !== 'actions' && typeIdentifier !== 'transformed' && - typeIdentifier !== 'ampdevmode') { + typeIdentifier !== 'data-ampdevmode') { hasMandatoryTypeIdentifier = true; } // The type identifier "transformed" has restrictions on it's value. @@ -5209,7 +5209,7 @@ class ParsedValidatorRules { validationResult); } } - if (typeIdentifier === 'ampdevmode') { + if (typeIdentifier === 'data-ampdevmode') { // https://github.com/ampproject/amphtml/issues/20974 // We always emit an error for this type identifier, but it // suppresses other errors later in the document. @@ -5248,23 +5248,23 @@ class ParsedValidatorRules { switch (this.htmlFormat_) { case 'AMP': this.validateTypeIdentifiers( - htmlTag.attrs(), ['⚡', 'amp', 'transformed', 'ampdevmode'], context, - validationResult); + htmlTag.attrs(), ['⚡', 'amp', 'transformed', 'data-ampdevmode'], + context, validationResult); break; case 'AMP4ADS': this.validateTypeIdentifiers( - htmlTag.attrs(), ['⚡4ads', 'amp4ads', 'ampdevmode'], context, + htmlTag.attrs(), ['⚡4ads', 'amp4ads', 'data-ampdevmode'], context, validationResult); break; case 'AMP4EMAIL': this.validateTypeIdentifiers( - htmlTag.attrs(), ['⚡4email', 'amp4email', 'ampdevmode'], context, - validationResult); + htmlTag.attrs(), ['⚡4email', 'amp4email', 'data-ampdevmode'], + context, validationResult); break; case 'ACTIONS': this.validateTypeIdentifiers( - htmlTag.attrs(), ['⚡', 'amp', 'actions', 'ampdevmode'], context, - validationResult); + htmlTag.attrs(), ['⚡', 'amp', 'actions', 'data-ampdevmode'], + context, validationResult); if (validationResult.typeIdentifier.indexOf('actions') === -1) { context.addError( amp.validator.ValidationError.Code.MANDATORY_ATTR_MISSING, diff --git a/validator/testdata/feature_tests/dev_mode.html b/validator/testdata/feature_tests/dev_mode.html index efe020557779..6a563d390a6a 100644 --- a/validator/testdata/feature_tests/dev_mode.html +++ b/validator/testdata/feature_tests/dev_mode.html @@ -15,15 +15,15 @@ --> - + @@ -38,17 +38,17 @@ - - + + - + - + diff --git a/validator/testdata/feature_tests/dev_mode.out b/validator/testdata/feature_tests/dev_mode.out index 4e63aa8782d3..b8a42305f2e2 100644 --- a/validator/testdata/feature_tests/dev_mode.out +++ b/validator/testdata/feature_tests/dev_mode.out @@ -16,17 +16,17 @@ FAIL | --> | | -| +| >> ^~~~~~~~~ -feature_tests/dev_mode.html:26:0 Tag 'html' marked with attribute 'ampdevmode'. Validator will suppress errors regarding any other tag with this attribute. [GENERIC] +feature_tests/dev_mode.html:26:0 Tag 'html' marked with attribute 'data-ampdevmode'. Validator will suppress errors regarding any other tag with this attribute. [GENERIC] | | | @@ -45,17 +45,17 @@ feature_tests/dev_mode.html:38:2 The tag 'faketag' is disallowed. [DISALLOWED_HT >> ^~~~~~~~~ feature_tests/dev_mode.html:39:2 The tag 'anotherfaketag' is disallowed. [DISALLOWED_HTML] | -| -| +| +| | | -| +| | | | | -| +| | | | diff --git a/validator/testdata/feature_tests/no_dev_mode.html b/validator/testdata/feature_tests/no_dev_mode.html index 731f268babe8..cee3f6ad8d4a 100644 --- a/validator/testdata/feature_tests/no_dev_mode.html +++ b/validator/testdata/feature_tests/no_dev_mode.html @@ -15,15 +15,15 @@ --> @@ -42,14 +42,14 @@ - - + + - + - + diff --git a/validator/testdata/feature_tests/no_dev_mode.out b/validator/testdata/feature_tests/no_dev_mode.out index 533de875f5e0..1afc23bcfd4c 100644 --- a/validator/testdata/feature_tests/no_dev_mode.out +++ b/validator/testdata/feature_tests/no_dev_mode.out @@ -16,15 +16,15 @@ FAIL | --> | | @@ -47,12 +47,12 @@ feature_tests/no_dev_mode.html:42:2 The tag 'faketag' is disallowed. [DISALLOWED >> ^~~~~~~~~ feature_tests/no_dev_mode.html:43:2 The tag 'anotherfaketag' is disallowed. [DISALLOWED_HTML] | -| -| +| +| >> ^~~~~~~~~ feature_tests/no_dev_mode.html:46:2 The tag 'faketag' is disallowed. [DISALLOWED_HTML] | -| +| >> ^~~~~~~~~ feature_tests/no_dev_mode.html:48:2 The tag 'faketag' is disallowed. [DISALLOWED_HTML] | @@ -60,9 +60,7 @@ feature_tests/no_dev_mode.html:48:2 The tag 'faketag' is disallowed. [DISALLOWED feature_tests/no_dev_mode.html:49:4 The tag 'anotherfaketag' is disallowed. [DISALLOWED_HTML] | | -| ->> ^~~~~~~~~ -feature_tests/no_dev_mode.html:52:2 The attribute 'ampdevmode' may not appear in tag 'amp-autocomplete'. (see https://amp.dev/documentation/components/amp-autocomplete) [DISALLOWED_HTML] +| | | | diff --git a/validator/validator-main.protoascii b/validator/validator-main.protoascii index 37ad617d235f..d12d31de7305 100644 --- a/validator/validator-main.protoascii +++ b/validator/validator-main.protoascii @@ -26,7 +26,7 @@ min_validator_revision_required: 375 # newer versions of the spec file. This is currently a Google internal # mechanism, validator.js does not use this facility. However, any # change to this file (validator-main.js) requires updating this revision id. -spec_file_revision: 936 +spec_file_revision: 945 styles_spec_url: "https://amp.dev/documentation/guides-and-tutorials/develop/style_and_layout/style_pages" script_spec_url: "https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#html-tags" @@ -310,6 +310,7 @@ tags: { spec_name: "link rel=stylesheet for fonts" named_id: LINK_FONT_STYLESHEET mandatory_parent: "HEAD" + attr_lists: "nonce-attr" attrs: { name: "async" } attrs: { name: "crossorigin" } # SRI attribute (https://www.w3.org/TR/SRI/) attrs: { @@ -7348,6 +7349,6 @@ error_formats { } error_formats { code: DEV_MODE_ONLY - format: "Tag 'html' marked with attribute 'ampdevmode'. Validator " + format: "Tag 'html' marked with attribute 'data-ampdevmode'. Validator " "will suppress errors regarding any other tag with this attribute." }