[csswg-drafts] [css-syntax-3] Should forgiving grammars allow bad tokens? (#11966)

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

== [css-syntax-3] Should forgiving grammars allow bad tokens? ==
In [#11315](https://github.com/w3c/csswg-drafts/issues/11315#issuecomment-2567598772), I touched on bad tokens in declaration values defined with forgiving grammars. Browsers handle them differently.

Bad tokens are `<bad-string-token>`, `<bad-url-token>`, and orphan `)`, `]`, `}`. Per a non-normative note in CSS Syntax, they are always parse errors but are preserved in the token stream to define fine-grained error-handling in some places like the prelude of `@media`.

Indeed, some rule preludes are defined with forgiving grammars.

At the top level, `@media } {}` is interpreted as `@media not all {}`. Nested, it is invalid and ignored: `style { @media } {}`. Is this difference a problem?

Browsers also interpret `:is(}) {}` differently.

---

I do not see the usefulness of allowing bad tokens in forgiving grammars. Would it be a problem to make them invalid in forgiving grammars?

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


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

Received on Wednesday, 19 March 2025 15:22:33 UTC