Skip to content

[css-values-5] Forwards compatibility for inline if() #10818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andruud opened this issue Sep 2, 2024 · 4 comments
Closed

[css-values-5] Forwards compatibility for inline if() #10818

andruud opened this issue Sep 2, 2024 · 4 comments

Comments

@andruud
Copy link
Member

andruud commented Sep 2, 2024

Regardless of the outcome of #10064, should we implement something like <general-enclosed> for forwards compat?

For example:

background: if(
    future-thing(...): blue,
    style(--status:error): red,
    style(--status:warning): yellow,
    else: green
);

In the above, we probably want future-thing(...) to evaluate to false, rather than making the whole if invalid?

@LeaVerou @tabatkins

@LeaVerou
Copy link
Member

LeaVerou commented Sep 2, 2024

This sounds like a great idea. In fact, what is the widest set of parse-able tokens we could allow there and simply have them evaluate to false? Does it change based on whether we use : or ? as the condition terminating token?

@andruud
Copy link
Member Author

andruud commented Sep 2, 2024

For comma/else, I think pretty much any comma/semicolon-separated item matching <declaration-value> ':' <declaration-value>? could be valid?

For :?, I guess it's <declaration-value> '?' <declaration-value>? for :-separated items?

@tabatkins
Copy link
Member

While a <declaration-value> that excludes top-level : tokens is grammatically okay (that chunk of syntax is language-defined, so we're not applying restrictions to broader CSS development by adding that exclusion), it's not a good idea. The proposal was to use the <boolean> production that's already shared by MQs, SQs, and CQs, precisely so we could get general-enclosed and give it a truth value.

I think it needs to use the 3-value syntax like MQs, tho - if the UA doesn't understand the condition, it doesn't know whether the condition is true or false, so it shouldn't treat not gibberish() as true. (As opposed to an SQ, where unknown things are by definition false most of the time.)

@tabatkins
Copy link
Member

With the addition of <boolean[]>, if() is now well-defined in this regard, so I'm closing this issue as handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants