[css-syntax] Give up on production? · Issue #8835 · w3c/csswg-drafts (original) (raw)
In the previous versions of Syntax I tried my best to be grammar-agnostic, so you could parse CSS generically, and only throw out invalid rules/declarations as a final step. Implementations actually grammar-checked as they went and didn't add invalid stuff to the stylesheets, but that was meant to be an unobservable performance optimization.
However, we also wanted to fix the "u+a { color: red; }
is invalid because <urange>
isn't valid in a selector" problem; CSS2 defined <urange>
as a generic token. We discussed this in the mailing list (transferred to #3588), and I ended up solving it by defining a very complex production that required preserving the representation of tokens, which nothing else in the whole spec required. Accordingly, no browser has actually implemented this: Chrome just never fixed the bug, and Firefox implemented it by invoking a different tokenizer.
(<an+b>
is also now a complex production, but aside from preserving whether a positive number had a +
or not, it relied on the standard token values, so wasn't as problematic. Everybody seems to have actually followed the spec text.)
However, now that Syntax is required to grammar-check as it parses, we can potentially correct this in a less weird way, by having a tokenizer flag that gets invoked only for the 'unicode-range' descriptor and allows the tokenizer to produce urange tokens again. This'll better match what Firefox is doing, and should make it easy for Chrome to correctly implement as well.
Thoughts?