Skip to content

In An+B notation, it should be invalid to have comment between "A" and "n" #138

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

Closed
upsuper opened this issue Apr 13, 2017 · 7 comments
Closed

Comments

@upsuper
Copy link
Contributor

upsuper commented Apr 13, 2017

Things like :nth-child(-1/**/n+1) should be invalid.

It is not clear to me whether the spec matches that.

cc @SimonSapin

@SimonSapin
Copy link
Member

What is "should" if not according to a spec?

@upsuper
Copy link
Contributor Author

upsuper commented Apr 13, 2017

The spec says inserting whitespace there is invalid, so presumably adding comment is invalid as well? I suspect it indicates that An should be an unbreakable token?

@upsuper
Copy link
Contributor Author

upsuper commented Apr 13, 2017

So, yeah, An is a dimension token according to the spec, so it should be unbreakable: https://drafts.csswg.org/css-syntax-3/#the-anb-type

@SimonSapin
Copy link
Member

Without the comment, -1n+1 tokenizes as a dimention token with unit n, followed by a number token with an explicit plus sign. This matches <n-dimension> <signed-integer> in https://drafts.csswg.org/css-syntax/#the-anb-type.

With the comment it becomes an integer token, then an ident token, then an integer token with a plus sign. This does not match that grammar.

@SimonSapin
Copy link
Member

If I add "-1/**/n+1", null, (expecting a parse error) to src/css-parsing-tests/An+B.json, unit tests still pass. So is there anything to do here?

@upsuper
Copy link
Contributor Author

upsuper commented Apr 13, 2017

Oh, it seems I misunderstood the test result. It is Gecko who's wrong on this.

@upsuper upsuper closed this as completed Apr 13, 2017
@SimonSapin
Copy link
Member

SimonSapin commented Apr 13, 2017

(Gecko was correct according to the Selectors Level 3 definition: ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]?, but that bit of grammar was weird of sort-of incompatible with the usual CSS tokenization.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants