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 Roll-up #2711

Merged
merged 18 commits into from
Mar 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
23cbac8
Make the css selector node class inherit from the token class.
powdercloud Mar 26, 2016
b77eabe
Support `<a rel="noopener">`. Github #2641.
Gregable Mar 26, 2016
bc6480e
Allow https://fonts.googleapis.com/icon (Material Icons) as fonts. Gi…
Gregable Mar 26, 2016
f4fcd3a
Add new json tag.
Gregable Mar 26, 2016
d40a341
Simple css selector library refactorings.
powdercloud Mar 26, 2016
e07b081
Update the format string for CSS_SYNTAX_EOF_IN_PRELUDE_OF_QUALIFIED_R…
powdercloud Mar 26, 2016
eddc6fd
Update to parse-srcset.
honeybadgerdontcare Mar 26, 2016
eba6adf
Add full support for parsing attribute selectors.
powdercloud Mar 26, 2016
b11d905
Allow whitespace when parsing attribute selectors.
powdercloud Mar 26, 2016
74368f5
More specific error message for duplicate dimensions in srcsets attri…
honeybadgerdontcare Mar 26, 2016
cb6f7bf
In amp-accordion sections, support header (in addition to h1-h6).
powdercloud Mar 26, 2016
c4b4a84
Add template attribute to `<amp-list>`. Github #2517
Gregable Mar 26, 2016
7ad270f
Parse attributes that start with '/', when inside a tag, appropriately.
honeybadgerdontcare Mar 26, 2016
7f2efb2
Validate amp-social-share.
erwinmombay Mar 26, 2016
ab51b55
Allow <link rel="standout" href="...">. (#2705)
honeybadgerdontcare Mar 26, 2016
5c785f5
Slight cleanup of css-selectors.js.
powdercloud Mar 26, 2016
015f3b7
Add missing super() calls.
Gregable Mar 26, 2016
76707bf
Add a JavaScript hook to match validator errors to specific tags in a…
Gregable Mar 26, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
522 changes: 322 additions & 200 deletions validator/css-selectors.js

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions validator/htmlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ amp.htmlparser.DocLocator = class {
*/
amp.htmlparser.HtmlSaxHandlerWithLocation = class
extends amp.htmlparser.HtmlSaxHandler {
constructor() {}
constructor() { super(); }

/**
* Called prior to parsing a document, that is, before {@code startTag}.
Expand Down Expand Up @@ -612,11 +612,13 @@ amp.htmlparser.HtmlParser.INSIDE_TAG_TOKEN_ = new RegExp(
// interpreters are inconsistent in whether a group that matches nothing
// is null, undefined, or the empty string.
('(?:' +
// We don't allow attribute names starting with '/', but we allow them
// to contain '/' (differing from HTML5 spec), so that we can identify
// full mustache template variables and emit matching errors.
'([^\\t\\r\\n /=>][^\\t\\r\\n =>]*)' + // attribute name
('(' + // optionally followed
// Allow attribute names to start with /, avoiding assigning the / in
// close-tag syntax */>.
'([^\\t\\r\\n /=>][^\\t\\r\\n =>]*|' + // e.g. "href"
'[^\\t\\r\\n =>]+[^ >]|' + // e.g. "/asdfs/asd"
'\/+(?!>))' + // e.g. "/"
// Optionally followed by:
('(' +
'\\s*=\\s*' +
('(' +
// A double quoted string.
Expand Down Expand Up @@ -674,6 +676,7 @@ extends amp.htmlparser.DocLocator {
* @param {string} htmlText text of the entire HTML document to be processed.
*/
constructor(htmlText) {
super();
// Precomputes a mapping from positions within htmlText to line /
// column numbers. TODO(johannes): This uses a fair amount of
// space and we can probably do better, but it's also quite simple
Expand Down
2 changes: 2 additions & 0 deletions validator/htmlparser_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ goog.provide('amp.htmlparser.HtmlParserTest');
*/
class LoggingHandler extends amp.htmlparser.HtmlSaxHandler {
constructor() {
super();
this.log = [];
}

Expand Down Expand Up @@ -183,6 +184,7 @@ describe('HtmlParser', () => {
class LoggingHandlerWithLocation
extends amp.htmlparser.HtmlSaxHandlerWithLocation {
constructor() {
super();
/** @type {amp.htmlparser.DocLocator} */
this.locator = null;
/** @type {!Array<!string>} */
Expand Down
32 changes: 19 additions & 13 deletions validator/parse-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,19 +452,23 @@ class Canonicalizer {
const contents = parse_css.extractASimpleBlock(tokenStream);

switch (this.blockTypeFor(rule)) {
case parse_css.BlockType.PARSE_AS_RULES:
rule.rules = this.parseAListOfRules(
contents, /* topLevel */ false, errors);
break;
case parse_css.BlockType.PARSE_AS_DECLARATIONS:
rule.declarations = this.parseAListOfDeclarations(contents, errors);
break;
case parse_css.BlockType.PARSE_AS_IGNORE:
break;
default:
goog.asserts.fail(
'Unrecognized blockType ' + this.blockTypeFor(rule));
break;
case parse_css.BlockType.PARSE_AS_RULES: {
rule.rules = this.parseAListOfRules(
contents, /* topLevel */ false, errors);
break;
}
case parse_css.BlockType.PARSE_AS_DECLARATIONS: {
rule.declarations = this.parseAListOfDeclarations(contents, errors);
break;
}
case parse_css.BlockType.PARSE_AS_IGNORE: {
break;
}
default: {
goog.asserts.fail(
'Unrecognized blockType ' + this.blockTypeFor(rule));
break;
}
}
return rule;
}
Expand Down Expand Up @@ -861,6 +865,8 @@ class UrlFunctionVisitor extends parse_css.RuleVisitor {
* @param {!Array<!parse_css.ErrorToken>} errors
*/
constructor(parsedUrls, errors) {
super();

/** @type {!Array<!parse_css.ParsedCssUrl>} */
this.parsedUrls = parsedUrls;
/** @type {!Array<!parse_css.ErrorToken>} */
Expand Down
Loading