Re: [csswg-drafts] [css-values] Short-circuit if() evaluation (#11500)

I like the idea of early and later grammars, especially if this allows us to do `var(var(--foo))`. However, I had one question about:

> […] This also means we don't actually _resolve_ the `var(--fallback)` unless it's needed, which is nice, as it means you don't get cycles from unused fallback. This is actually somewhat unintentional, tho!

According to the https://www.w3.org/TR/css-variables-1/#cycles, 

> If the value of a custom property _prop_ contains a `var()` function referring to the property _var_ (including in the fallback argument of `var()`), add an edge between _prop_ and the _var_.

Note the “including in the fallback argument”.

All browsers comply with this part, which led to me writing this article, where I found a use for this fact: https://kizu.dev/indirect-cyclic-conditions/

That said, the technique in this article is purely for conditionals, and could be retired once we will have `if()`, _but_ it can be used now for working around the absence of native conditionals. In my opinion, it could be helpful to keep it this way, so tools like Lightning CSS and PostCSS could potentially transpile native conditionals into the indirect cyclic conditions, although I imagine not all cases will be still possible. I doubt there are potential web compat issues aside from this technique for this, but there could still be something (and I am already [starting to use this technique](https://kizu.dev/preview-mixin/) more and more, oops).

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


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

Received on Thursday, 13 February 2025 21:59:55 UTC