Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator rollup #24986

Merged
merged 2 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 26 additions & 26 deletions validator/engine/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,30 +651,6 @@ class ParsedTagSpec {
sortAndUniquify(this.mandatoryOneofs_);
sortAndUniquify(this.mandatoryAnyofs_);
sortAndUniquify(this.mandatoryAttrIds_);

if (tagSpec.extensionSpec !== null) {
this.expandExtensionSpec();
}
}

/**
* Called on a TagSpec which contains an ExtensionSpec, expands several
* fields in the tag spec.
*/
expandExtensionSpec() {
const {extensionSpec} = this.spec_;
if (this.spec_.specName === null)
{this.spec_.specName = extensionSpec.name + ' extension .js script';}
this.spec_.mandatoryParent = 'HEAD';
if (this.spec_.extensionSpec.deprecatedAllowDuplicates)
{this.spec_.uniqueWarning = true;}
else
{this.spec_.unique = true;}

if (amp.validator.VALIDATE_CSS) {
this.spec_.cdata = new amp.validator.CdataSpec();
this.spec_.cdata.whitespaceOnly = true;
}
}

/**
Expand Down Expand Up @@ -2695,8 +2671,8 @@ class Context {
* @private
*/
recordValidatedFromTagSpec_(parsedTagSpec) {
if (!this.tagspecsValidated_.hasOwnProperty(parsedTagSpec.id()))
{this.tagspecsValidated_[parsedTagSpec.id()] = true;}
if (parsedTagSpec.shouldRecordTagspecValidated())
this.tagspecsValidated_[parsedTagSpec.id()] = true;
}

/**
Expand Down Expand Up @@ -5046,6 +5022,30 @@ class ParsedValidatorRules {
this.typeIdentifiers_['transformed'] = 0;
this.typeIdentifiers_['data-ampdevmode'] = 0;

// For every tagspec that contains an ExtensionSpec, we add several TagSpec
// fields corresponding to the data found in the ExtensionSpec.
this.expandExtensionSpec_ = function() {
const numTags = this.rules_.tags.length;
for (let tagSpecId = 0; tagSpecId < numTags; ++tagSpecId) {
let tagSpec = this.rules_.tags[tagSpecId];
if (tagSpec.extensionSpec == null) continue;
if (tagSpec.specName === null)
tagSpec.specName =
tagSpec.extensionSpec.name + ' extension .js script';
tagSpec.mandatoryParent = 'HEAD';
if (tagSpec.extensionSpec.deprecatedAllowDuplicates)
tagSpec.uniqueWarning = true;
else
tagSpec.unique = true;

if (amp.validator.VALIDATE_CSS) {
tagSpec.cdata = new amp.validator.CdataSpec();
tagSpec.cdata.whitespaceOnly = true;
}
}
};
this.expandExtensionSpec_();

/**
* @type {function(!amp.validator.TagSpec) : boolean}
* @private
Expand Down
1 change: 1 addition & 0 deletions validator/testdata/amp4ads_feature_tests/extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@
src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
</head>
<body></body></html>

2 changes: 1 addition & 1 deletion validator/testdata/amp4ads_feature_tests/extensions.out
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ amp4ads_feature_tests/extensions.html:121:19 The extension 'amp-animation' was f
>> ^~~~~~~~~
amp4ads_feature_tests/extensions.html:121:19 The extension 'amp-lightbox' was found on this page, but is unused. Please remove this extension. [AMP_TAG_PROBLEM]
>> ^~~~~~~~~
amp4ads_feature_tests/extensions.html:121:19 The extension 'amp-mustache' was found on this page, but is unused. Please remove this extension. [AMP_TAG_PROBLEM]
amp4ads_feature_tests/extensions.html:121:19 The extension 'amp-mustache' was found on this page, but is unused. Please remove this extension. [AMP_TAG_PROBLEM]
2 changes: 1 addition & 1 deletion validator/validator-main.protoascii
Original file line number Diff line number Diff line change
Expand Up @@ -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: 960
spec_file_revision: 961

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"
Expand Down