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

@AmeliaBR Ah, I didn't see your last comment before the call, and thus misunderstood your comment during the call. You're right, `background` is indeed ambiguous if we allow a trailing comma after the `#` term.

Since Oriol and Emilio both expressed preference for just allowing it at end of a function/property, and I don't think it negatively affects any existing property or function, I'm happy to switch to that.

So, that still leaves us with two possibilities, afaict.

1. Property or function grammars that contain either a top-level `,` combinator or `#` multiplier allow an optional final comma at the end of their value.
2. All properties and functions allow a trailing final comma that is stripped from their value by the Syntax parser.

If I understood them correctly, Emilio preferred handling this at the lowest level possible, to minimize the chance of someone forgetting to implement it, so they'd prefer (2).  I think I'm okay with that. I first thought it was kinda weird to allow something like `content: attr(foo,);`, but then realized that if attr() had an optional comma-separated argument (which it *does* now in Values 4), that would be valid and fine; it's not great to have the validity of this change over time, so it's better to allow it all the time up-front.

This does allow oddities like `color: blue,;`, but heck, maybe someday we will make `color` comma-separated. And disallowing things that look weird but nobody will actually do isn't very important; we're not protecting anyone from anything. The gain in overall conceptual simplicity, since it would be addressed at the parser level, seems like a great win too.

So, when we pick this up (at the f2f I guess?) I propose that we accept (2), and I make edits to Syntax to make all functions and properties accept a final trailing comma, which is removed during parsing.

Specifically, I'd add a penultimate step to <https://drafts.csswg.org/css-syntax/#consume-a-declaration> dropping a single comma token, and add a similar bit dropping trailing ws and commas from the function value in <https://drafts.csswg.org/css-syntax/#consume-function>.

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

Received on Wednesday, 22 April 2020 17:10:11 UTC