Re: [csswg-drafts] [css-values?] What is the MVP for inline conditionals on custom properties? (#10064)

> @LeaVerou I don't understand the problem.

If we use a different character to separate the condition from the values (say `?` or `:`), then `if(style(...) ? foo, bar)` is ambiguous: is `foo, bar` as a whole the _if true_ value, or is the comma a separator? This is because the first time we encounter the separator is when it separates the _if true_ value from the _if false_ value, and we don’t know when to stop parsing these, so we *rely* on the separator. However, the grammar for conditions is far more restricted, so we *know* when we’ve stopped parsing the condition, and the character that follows (`;` or `,`) is the function separator, so `if(style(...), foo, bar)` has no such ambiguity.

The other ways to address it are to make the last argument mandatory and either:
1. Allow empty values there (`if(style(...) ? foo)`)
2. Introduce a keyword to represent an empty token stream (`if(style(...) ? foo, no-value)`)

That said, you may want to use an empty value for the _if true_ condition, so these may be orthogonal (though you can always negate the condition, so that’s just syntactic sugar). We could discuss what that value would look like in #10441 .

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


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

Received on Thursday, 13 June 2024 11:02:22 UTC