- From: Ojan Vafai <ojan@chromium.org>
- Date: Wed, 19 Dec 2012 11:49:36 -0500
- To: "Tab Atkins Jr." <jackalmage@gmail.com>
- Cc: www-style list <www-style@w3.org>
- Message-ID: <CANMdWTsRY=Z+NSZQ2XeC_2hEc=VwN5WWzGpcG-7gt2kXiNOkyw@mail.gmail.com>
On Tue, Dec 18, 2012 at 2:29 PM, Tab Atkins Jr. <jackalmage@gmail.com>wrote: > This is something that's been bugging me for a while. > > Most of the time, CSS just uses whitespace as a separator between > values. This works great, because if a term is omitted, the implied > whitespace on either side just collapses into a single whitespace > block, so you don't have to worry about "too much" whitespace being > left around when a term is omitted. > > Sometimes, though, we use a comma to separate terms, and it doesn't > have this behavior. If a term is completely omitted, you have to > carefully construct the grammar to force an associated comma to also > be omitted. I don't think this helps your problem, but why don't we want to allow trailing commas? After many years of web devs cursing at JS for now allowing trailing commas, finally all modern browsers do. CSS should allow them as well. > This distorts a bunch of grammars, forcing a lot of extra > wrappers and duplication of terms, making them harder to read than > they should be. One of the major purposes of our grammar is to be a > relatively easily-understandable description of the allowed values, so > this is a failure. > > Could we perhaps define the use of the comma in grammars to have this > behavior automatically? Here's some before/after examples of how this > would help. > > radial-gradient(): > [ [ <shape> || <size> ] [ at <position> ]? , | > at <position>, > ]? > <color-stop-list> > ==> > [ <shape> || <size> ]? [ at <position> ]? <color-stop-list> > > image(): > <image-tags>? [ <image-src> , ]* [ <image-src> | <color> ] > ==> > <image-tags>? <image-src># , <color>? > > image-set(): > [ <image-set-decl>, ]* [ <image-set-decl> | <color>] > ==> > <image-set-decl># , <color>? > > > > Specifically, the rule would be that, a comma must be omitted if, > ignoring whitespace and comments, it would be the first or last token > in the function/property value, or if the immediately preceding token > is also a comma. Informally, commas must separate terms, so omit them > if they don't. > > ~TJ > >
Received on Wednesday, 19 December 2012 16:50:29 UTC