Re: [csswg-drafts] [css-values][css-images] Allow trailing comma in gradient functions (and probably others) (#4968)

Overall makes sense to me.

Wrt the special cases, e.g. for 'background': typically the last item is unambiguously part of the final construction: it is required, and is not part of the "list". The last case is special because it allows things that aren't allowed in the generic list, but it can still match the generic list grammar: a given declaration might not necessarily include the parts which are "final" in the last item. Such a last item is not restricted to be the final item and the author could add more to the list afterwards. So it would be good to allow a trailing comma in these cases.

> One way to do this would be to define a new multiplier which explicitly requires a trailing comma

We don't need to do that. These cases already have to include an explicit trailing comma in their grammar, otherwise the current grammars wouldn't actually work. :)

> and then explicitly add an optional trailing comma after the last special item

Either that, or make the last item itself optional. This would make a grammar somewhat ambiguous: you don't know if you're in a "final item" pattern unless you hit one of the otherwise-disallowed components. But it would correctly represent all possible productions. E.g.
```
background: [ [ <layer># , ]? [ <final-layer> ,? ]? ]!
```
instead of
```
background: [ <layer># , ]? <final-layer>
```

Note that the comma has [special rules](https://www.w3.org/TR/css-values-3/#component-types) that prevent duplicates at a single point in the grammar, so `# ,` does not create problems even if # allows a trailing comma.

p.s. I really dislike the ! multiplier as a solution to this grammar stuff, there's just too many brackets. Wish we had [went with](https://github.com/w3c/csswg-drafts/issues/687) a combinator that meant "either or both but in this order".


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

Received on Tuesday, 30 June 2020 21:32:08 UTC