Comments

edited

When encountering /* in the token stream, the tokenizer algorithm described in Syntax Level 3 states:

If the next input code point is U+002A ASTERISK (), consume it and all following code points up to and including the first U+002A ASTERISK () followed by a U+002F SOLIDUS (/), or up to an EOF code point. Then consume a token and return it.

The tokenizer described in this specification does not produce tokens for comments, or otherwise preserve them in any way. Implementations may preserve the contents of comments and their location in the token stream. If they do, this preserved information must have no effect on the parsing step.

This means that the tokenizer must effectively ignore comments, or, if it emits tokens for comments, ignore them during parsing. If comments occur at token boundaries, they should have absolutely no effect. This will work in every major browser, but won't validate:

./**/foo/**/:/**/hover {}

This will validate:

.foo/**/:hover {}

Note that for both examples, all comments are located at token boundaries. The tokenizer must parse it as:

[DELIM "."] [IDENT "foo"] [COLON] [IDENT "hover"] [WHITESPACE]...

I know that this might seem very pedantic, and I totally understand if this issue goes too far, so just consider this an FYI if somebody encounters this problem.