Re: [csswg-drafts] [mediaqueries] Spec has conflicting info on whether or not `<media-query-list>` allows trailing commas (#11254)

> The trailing whitespace in my example was unintentional, sorry. It does not make any difference: `matchMedia('all, ').media === matchMedia('all,').media` is true. The last list item is either a whitespace token or empty, which then does not make a difference when parsing against the grammar (`<media-query>`).

Without whitespace, the last item, as per my understanding of the spec, should be `all`, not empty:
Since [parse a comma-separated list of component values](https://drafts.csswg.org/css-syntax-3/#parse-a-comma-separated-list-of-component-values) will, while input is not empty:
1. [Consume a list of component values](https://drafts.csswg.org/css-syntax-3/#consume-a-list-of-component-values) from input, with [&lt;comma-token&gt;](https://drafts.csswg.org/css-syntax-3/#typedef-comma-token) as the stop token, and append the result to groups. (This consumes `all` and adds it to the list to be returned)
2. [Discard a token](https://drafts.csswg.org/css-syntax-3/#token-stream-discard-a-token) from input. (This discards the trailing comma)
3. Now input is empty, so the list containing only an `all` will be returned.

Note that both Firefox and Chrome don't do it like this, so I'm either misunderstanding something or this is a spec or browser bug.

-- 
GitHub Notification of comment by Psychpsyo
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11254#issuecomment-2490678990 using your GitHub account


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

Received on Thursday, 21 November 2024 10:12:57 UTC