Re: [csswg-drafts] [css-values-5][various] Better handling of arguments with commas (#9539)

Strong +1 to what Tab is proposing here.

> > we wouldn't allow {} wrappers just anywhere
> 
> So if a function accepts a single parameter, then `f({a})` uses `{a}` as the argument, but then if we add a 2nd optional parameter, then the argument will suddenly change to `a`? Seems bad for forwards compatibility.

Good point, but this would only be a problem for functions that accept `{}` in their parameters, right? So maybe there's no need to allow e.g. `rgb({0}, {128}, {0})`, since that's already invalid.

> Would `var(--foo, {"foo.svg", "bar.svg"})` resolve to `"foo.svg", "bar.svg"` or to `{"foo.svg", "bar.svg"}`?

This currently resolves to `{"foo.svg", "bar.svg"}`, and changing that definitely requires a use-counter. We _might_ be able to change this to optionally allow `{}` if we wanted, but we shouldn't rely on it. I highly doubt we'll be able to _require_ `{}`, though.

Related question: it may be too late for `var()`/`env()`, but what about `attr()`?

> If the former, does that mean that `if(cond(...): var(--foo))` resolves to `"foo.svg"` if `cond(...)` is true? If the latter, does that mean that `prop: var(--foo)` is invalid?

I don't think [arbitrary substitution functions](https://drafts.csswg.org/css-variables/#arbitrary-substitution) should be allowed to mess with the grammar of the calling function itself, just like you're not allowed to paste e.g. a fallback into another `var()`: `--fb:, myfallback;  --y: var(--x var(--fb)) /* invalid */`.

So when `--foo` is `"foo.svg", "bar.svg"`, then `--bar: if(cond(...): var(--foo))` is `"foo.svg", "bar.svg"` when the condition is true, and IACVT when the condition is false.

When `--foo` is `{"foo.svg", "bar.svg"}`, then `--bar: if(cond(...): var(--foo))` is `{"foo.svg", "bar.svg"}` when the condition is true, and IACVT when the condition is false.

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


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

Received on Wednesday, 25 September 2024 08:50:14 UTC