-
Notifications
You must be signed in to change notification settings - Fork 41
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
HASH - IDENT multiple matches #15
Comments
I don't understand what you mean. The only possible tokens that can start with a # are DELIM and HASH. The HASH token, as it would consume three characters to the DELIM's one, wins. I have no idea what you mean by claiming that the ident token would produce a longer match. IDENT tokens can't start with a #, so they seem irrelevant. The correct sequence of tokens for "#id {top:1px}" is: HASH(#id) |
Thanks for the fast response. I do understand what you are saying and I am probably not explaining myself correctly. According to : 6.5. ID selectors "An ID selector contains a "number sign" (U+0023, #) immediately followed by the ID value, which must be an CSS identifiers." The sequence of tokens for "#id {top:1px}" is: The sequence of tokens for "#123id {top:1px}" is: Both have the same HASH token in selectors but only one selector in valid as the other one starts with a number: #123id. So in order to validate an id selector you would need "#" IDENT. I can not find the productions for ids, classes and elements are clearly specified like this at http://www.w3.org/TR/selectors/#w3cselgrammar: element_name class Thank you. |
In order to validate an ID selector, you need different rules than what you use to parse an ID selector. "#123id" is a perfectly fine HASH token, but it's an invalid id selector. There's nothing wrong with that disconnect, as the two concepts live at different levels. It's similar to how a property name must be a valid property name from the list of known CSS properties, but the grammar only constrains it to being an "ident". The sequence of tokens DELIM(#) IDENT can not occur in the CSS parser, because # followed by a character is just a HASH token. Note that in the Selectors 3 grammar, the grammar for the simple_selector_sequence production just includes HASH directly, rather than having a separate "id" production. |
Ok, thanks for the explication. Indeed the simple_selector_sequence production just includes HASH and not DELIM. |
EDIT:
Also filed here: https://www.w3.org/Bugs/Public/show_bug.cgi?id=17511 Thank you |
Giving the following rule:
id {top:1px}
The tokenizer returns a HashToken for the "#id" selector. This does not seems to be the correct behavior. It should return an IDENT token since according to the http://www.w3.org/TR/css3-syntax/#tokenization :
"In case of multiple matches, the longest match determines the token."
Also a HashToken may be invalid in a selector because it can contain a num as the first character - Illegal in an ID selector.
I think that this should be returned:
id {top:1px} - IDENT
1id {top:1px} - HASH
Thank you.
The text was updated successfully, but these errors were encountered: