Open drott opened 2 years ago
CC @tabatkins
Anders points to #6641; in there I say that "author env()" isn't great because it means that, in many cases, you'll be forced to duplicate the same information in both places. Most variables are document-global anyway, so the choice of whether you do it as a var()-on-root or author-defined env() would be mostly arbitrary, and having to decide between the two wouldn't be ideal.
I'm supportive of the idea Anders hit in that thread, of allowing these sorts of non-element cases to use the initial value of custom properties, which are provided by @property
. That satisfies the use-case of "author-level env()" while simultaneously continuing to act as a normal custom property. I think that would be appropriate here as well.
This keeps coming up. We don't want authors to be duplicating colors in these rules, but also we don't want a dependency on the root element's computed style.
What if we define a new rule (::document
?) where authors can define values for custom properties that are above the root node, i.e. akin to applying to the actual document node. Then media queries and other at rules can use var()
references, and they'd resolve relative to that, and because it's not an element, nothing depends on any element's computed style.
@LeaVerou do you have an objection to the suggestion Anders made, to rely on the initial value of custom props, as defined by @property
? Note that you can nest @property in MQs and other conditionals if needed, to supply the "right" initial value.
@tabatkins
@LeaVerou do you have an objection to the suggestion Anders made, to rely on the initial value of custom props, as defined by
@property
? Note that you can nest @Property in MQs and other conditionals if needed, to supply the "right" initial value.
I think that's a clumsy solution, as it requires a new @property
rule for every single property. Authors tend to define A LOT of properties in their root rules (eg). Even when @property
is widely supported, I don't see authors using it for every single custom property they define.
Certainly better than nothing though!
I'm operating under the following constraints:
Beyond satisfying those 2 constraints, I have no opinion how this gets resolved.
No worries, this is being discussed in #6641 for a general solution.
So, should we close this issue and use whatever general solution emerges from
In https://github.com/w3c/csswg-drafts/issues/6631#issuecomment-1004861176 @andruud suggests that usage of
var()
inside@font-palette-values
is unconventional compare to the usual usage ofvar()
.We may want to disallow
var()
usage in@font-palette-values
or - if that's not acceptable - specify it differently, so that it's evaluated in the element's context if really needed / possible.@andruud's feedback:
Spec text after ee8dada50f9: