Re: [csswg-drafts] [css-variables] Should `var(var(--x))` work? (#11144)

> @andruud That is already the case, unless `‑‑x` is a [registered custom property](https://drafts.css-houdini.org/css-properties-values-api-1/#registered-custom-property) with a non‑[universal syntax definition](https://drafts.css-houdini.org/css-properties-values-api-1/#universal-syntax-definition).

@ExE-Boss Ah, right, I forgot that we changed to that behavior in https://github.com/w3c/csswg-drafts/pull/6006. (I even changed it myself ...)

That's all good, then.

> Right now, with var(--foo, var(--bar)), you know exactly what the bounds of the fallback is, so you can avoid actually interpreting it unless it's needed. If var(--bar) doesn't exist or whatever, you won't even know unless fallback actually gets triggered and you have to process the fallback tokens.

That's not true. We (currently) have to resolve any var() in the fallback to look for cycles, even when the fallback is not taken. However, the fallback being (or containing) guaranteed-invalid has no effect unless the fallback _is_ taken.

> the invalidity of the fallback shouldn't matter unless you actually use it.

It is already the case.
 
> I think, to be a little more specific, the rule would be that if a substitution function fails to parse, it's substitutes _as itself_, but with all of its tokens "marked as meaningless" - meaningless tokens don't have any behavior and don't match any grammar except the "anything goes" ones like `<declaration-value>`. If a substitution function's "result" (from its [substitution algo](https://drafts.csswg.org/css-values-5/#substitute-arbitrary-substitution-function)) contains any meaningless tokens, it triggers fallback if it also returned a "fallback" value; if no fallback was specified, it just substitutes as normal (but with some meaningless tokens).

This sounds _awful_, and likely a non-starter. But I also don't see why it's _needed_.

It's possible that we actually agree on how this should all work, but with entirely different mental models. I need to process what you wrote a bit more and see if I can come up with an alternative way to describe the behavior ...

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


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

Received on Wednesday, 6 November 2024 08:46:38 UTC