Re: [csswg-drafts] [css-pseudo] Custom properties on :root (#6641)

The CSS Working Group just discussed `Custom properties on :root`.

<details><summary>The full IRC log of that discussion</summary>
&lt;emeyer> Topic: Custom properties on :root<br>
&lt;emeyer> github: https://github.com/w3c/csswg-drafts/issues/6641<br>
&lt;fantasai> -> https://github.com/w3c/csswg-drafts/issues/6641#issuecomment-1367600040<br>
&lt;emeyer> TabAtkins: Authors often define a big set of custom properties on the root element<br>
&lt;emeyer> …These reasonably might want to be used in highlight pseudos<br>
&lt;emeyer> …Currently, highlight pseudos don]t inherit from the normal DOM tree<br>
&lt;emeyer> …So they won’t see any of the stuff on the root<br>
&lt;emeyer> …The way around that is to have that big block have a selector of `:root, ::highlight`<br>
&lt;emeyer> …It’s a little weird and funky<br>
&lt;emeyer> …There are a few suggestions to address this<br>
&lt;emeyer> …One is to have some kind of at-rule allowing you to apply custom properties at a level higher than the root, which highlight pseudos could see<br>
&lt;emeyer> …Another is to change things so that highlight pseudos resolve their vars against the originating element<br>
&lt;emeyer> …Another is to say highlight inherits all custom properties from the root<br>
&lt;miriam> q+<br>
&lt;bramus> q+<br>
&lt;fantasai> ... and maybe all properties from the root<br>
&lt;emeyer> …I don’t like resolving var() differently<br>
&lt;emeyer> …I think it would complicate or break setting vars directly on highlights<br>
&lt;emeyer> …Inheriting from the root element has possibilies, but could cause cascade problems<br>
&lt;emeyer> …Inheriting just custom properties would be a little weird; it has minimal impact but it’s a new way of doing things that might have implementation problems<br>
&lt;emeyer> …Having a root-superior at-rule is also a new weird way to address this<br>
&lt;bramus> A use-case for inheriting only custom properties is `::backdrop`<br>
&lt;emeyer> …Not really sure how to approach this, but leaving as is where you have to select both root and highlights has some implementor objections over memory cost<br>
&lt;fantasai> bramus, why?<br>
&lt;emeyer> miriam: ::backdrop has a similar problem and it’s caused author problems, and articles are starting to pop up about having to address both<br>
&lt;bramus> Authors want it: https://kilianvalkhof.com/2023/css-html/backdrop-doesnt-inherit-from-anywhere/<br>
&lt;emeyer> …I like ::document or something like that, maybe could also respond to dark and light modes<br>
&lt;emeyer> …I’m not sure a document-selecto toggle could respond, though<br>
&lt;fantasai> bramus, but ::backdrop could just inherit from its originating element like all pseudo-elements, couldn't it? why would you want it to inherit from :root specifically<br>
&lt;Rossen_> ack miriam<br>
&lt;Rossen_> ack bramus<br>
&lt;Rossen_> ack fantasai<br>
&lt;Zakim> fantasai, you wanted to distinguish ::backdrop<br>
&lt;emeyer> bramus: There’s author demand for backdrop inheriting custom props<br>
&lt;emeyer> fantasai: That is a little different, as ::backdrop can inherit from its originating element and we should make it do that<br>
&lt;emeyer> …highlights have to inherit from a tree parallel to the document tree<br>
&lt;bramus> Spec says it doesn’t: https://fullscreen.spec.whatwg.org/#::backdrop-pseudo-element<br>
&lt;bramus> “It does not inherit from any element and is not inherited from.”<br>
&lt;emeyer> …I can see reasons why we might want an @document<br>
&lt;TabAtkins> Right, spec says it doesn't, but we can't see any reason *why* it shouldn't inherit.<br>
&lt;bramus> True :)<br>
&lt;argyle> q+<br>
&lt;fremy> +1 to inherit custom properties from :root, I think they are de-facto considered "global" by authors<br>
&lt;emeyer> …Downside to inherit-from-root is that you can only ever get variables from the root, not from other elements between root and the highlight<br>
&lt;TabAtkins> We asked about it in the repo but haven't gotten a response<br>
&lt;Rossen_> ack argyle<br>
&lt;emeyer> argyle: If I do define a bunch of vars on @document I could toggle them, but it’s a good place to put them<br>
&lt;fremy> q+<br>
&lt;emeyer> …The at rule would be the place things are originally defined, but can be changed later<br>
&lt;emeyer> fremy: I don’t see why a document is different form an initial value in this case<br>
&lt;dbaron> argyle, what about miriam's point about things like light/dark mode depending both on media queries *and* an attribute on the root that comes from a user-facing toggle<br>
&lt;emeyer> …Why would we ask authors define things in @document and then ask them to redefine later<br>
&lt;argyle> dbaron:<br>
&lt;emeyer> Rossen_: Any other thoughts?<br>
&lt;Rossen_> ack fremy<br>
&lt;emeyer> (silence)<br>
&lt;emeyer> Rossen_: Do we feel like we’re close to resolution, or should we just capture this and pick it up next week?<br>
&lt;fremy> fremy: (for the minutes, I mentioned how developers already assume :root variables are global, and we could acknowledge them as-is)<br>
&lt;argyle> dbaron: @document { --brand: hotpink }, and for dark mode `@media (prefers-color-scheme: dark) { :root { --brand: deeppink } } .dark { --brand: deeppink }` is what i was thinkin<br>
&lt;emeyer> fantasai: Is there any reason we should NOT have the highlight pseudo inherit from :root?<br>
&lt;emeyer> TabAtkins: If you put color: black on root and then inherit into the highlight, it would break the cascade<br>
&lt;emeyer> fantasai: I think that can work by having the highlight tree break inheritance<br>
&lt;emeyer> …You can have paired default highlight colors happen based on author style rules<br>
&lt;dbaron> s/highlight tree/UA style sheet/<br>
&lt;dbaron> s/inheritance/inheritance for color/<br>
&lt;fremy> @ argyle what is the value of @document here? @property { initial } feels indentical (and, I believe, not that great in this case, you would want the deeppink in dark mode)<br>
&lt;TabAtkins> (I'm completely confused as to what fantasai is trying to say.)<br>
&lt;fantasai> s/highlight tree break inheritance/the UA stylesheet break inheritance/<br>
&lt;TabAtkins> (Either I, her, or both of us dont' understand what we're talking about.)<br>
&lt;emeyer> dbaron: A reason not to add it is that it still doesn’t solve the variables problem when they’re set on something other that the root<br>
&lt;emeyer> Rossen_: We’ll have to close here, the clock has run out<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6641#issuecomment-1404021071 using your GitHub account


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

Received on Wednesday, 25 January 2023 18:03:25 UTC