[csswg-drafts] [css-syntax-3] Tokenize comments into whitespaces (#11252)

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-syntax-3] Tokenize comments into whitespaces ==
The current version of Firefox accepts `calc(1/**/+ 1)` or `calc(1 +/**/1)` whereas the current version of Chrome does not. Per [spec](https://drafts.csswg.org/css-values-4/#calc-syntax), Chrome is correct.

There is no test for this on [WPT](https://github.com/web-platform-tests/wpt/blob/7e47e52d5496ce246ca27fa395cceaa0df8169b0/css/css-values/calc-invalid-parsing.html). Based on discussions in the www-style public archives, there was an intention to relax the whitespace requirement in the future.

Both browsers accept `:nth-child(+/**/n)` as a selector but not `U/**/+0-1` as a `unicode-range`. The related specs do not accept a whitespace at the place of the comment.

**Has it ever been considered to tokenize comments into whitespaces?**

This would make these cases more consistent. The non-normative requirement for the serialization of "any consecutive pair of tokens" (not separated by whitespaces) in [CSS Syntax 3 ยง 9. Serialization](https://drafts.csswg.org/css-syntax-3/#serialization) might then no longer be necessary.

I suspect the breaking change for `<an+b>` is ok. The unicode range [tests](https://github.com/web-platform-tests/wpt/blob/08455c56645a38e4e12f7782c62166c62e958e31/css/css-syntax/urange-parsing.html) on WPT still expect comments to be valid within the range, but I presume it will be updated at some point (related: #8835).

**Also, has it ever been considered to consume *a run of* whitespaces/comments into a single `<whitespace-token>`?**

There is currently no guarantee that a token stream does not include consecutive whitespaces. For example, the result from tokenizing `1 /**/ 1` includes two consecutive whitespaces.

This would not fix any problem but since consecutive whitespaces are collapsed, this seems consistent.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11252 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 20 November 2024 20:29:45 UTC