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;emilio> topic: custom properties on :root<br>
&lt;emilio> github: https://github.com/w3c/csswg-drafts/issues/6641<br>
&lt;emilio> delan: there's a lot of content out there where a bunch of custom properties are specified on the :root<br>
&lt;emilio> ... historically that's been fine for highlight pseudos because they inherited from the element<br>
&lt;emilio> ... as spec'd now each highlight pseudo has a separate inheritance tree so it'll break that pattern<br>
&lt;emilio> ... so there's a compat issue in that but I don't think that's a huge issue because we've determined that some breakage is acceptable for these highlight pseudo<br>
&lt;emilio> ... but there's two complications for this, one is that authors at least they'd have to switch their stylesheets to `:root, :root::selection, ...` etc<br>
&lt;TabAtkins> :root, :root::selection, :root::highlight, ... { /* set up all the custom props here */ }<br>
&lt;emilio> ... it's also a bit of a perf issue because we might end up with a bunch of property blobs<br>
&lt;emilio> ... there's another option which is using `@property` with an initial value<br>
&lt;emilio> ... it's a lot more verbose and it should work<br>
&lt;TabAtkins> q+<br>
&lt;emilio> ... I guess question is "is that good enough"? Or can we simplify it somehow for authors?<br>
&lt;Rossen_> ack fantasai<br>
&lt;emilio> fantasai: Wondering about two things we could possibly do. One of them is making highlights inherit from the root by default<br>
&lt;emilio> ... which might be a reasonable thing to do?<br>
&lt;emilio> ... or specifying that variables are special and they inherit from the originating element<br>
&lt;fantasai> probably can't inherit from :root for all properties, but for variables might be OK<br>
&lt;emilio> delan: I think the first idea seems cleaner<br>
&lt;emilio> ... I worry if there are any unintended side-effects<br>
&lt;emilio> q+<br>
&lt;emilio> fantasai: I think the idea is "if you're on the root selection" the variable properties would inherit from the root to `:root::selection`<br>
&lt;emilio> ... I wonder if we want to make this work for every element<br>
&lt;Rossen_> ack TabAtkins<br>
&lt;fantasai> TabAtkins: inheriting from originating element appeals, but assuming we want to inherit from a single place could address a larger concern<br>
&lt;emilio> TabAtkins: Inherit from originating element is appealing but if that doesn't happen this could be an opportunity to address a larger concern<br>
&lt;fantasai> TabAtkins: ....<br>
&lt;fantasai> TabAtkins: Argument for root, animations can play into that don't want to play into other places in the tree<br>
&lt;fantasai> scribenick: fantasai<br>
&lt;fantasai> TabAtkins: Few other suggestions, but if we are going to inherit all the highlights from a single place should do in a way that addresses larger concern<br>
&lt;fantasai> TabAtkins: either use initial value from register Properties<br>
&lt;fantasai> TabAtkins: or .... doesn't have animations apply to it<br>
&lt;fantasai> emilio: Want to point out that ::backdrop has the same issue, ::backdrop doesn't inherit from :root<br>
&lt;TabAtkins> s/..../a more ergonomic way to set initial values that/<br>
&lt;fantasai> emilio: it hasn't come up often, but it hsa come up sometimes<br>
&lt;fantasai> emilio: I would rather avoid inheriting from multiple places, because that's messy<br>
&lt;fantasai> emilio: very special-casy<br>
&lt;TabAtkins> like `@root { /* only custom props here */ }`<br>
&lt;fantasai> emilio: we do something like that for ::first-line, and it's a massive pain. Don't wish that to anyone<br>
&lt;fantasai> Rossen_: where do we go from here?<br>
&lt;fantasai> delan: Agree with emilio in general<br>
&lt;fantasai> delan: I think especially highlight inheritane, but a lot about highlight pseudos, is full of special cases<br>
&lt;fantasai> delan: would prefer to avoid adding more<br>
&lt;fantasai> delan: so maybe it's fine?<br>
&lt;Rossen_> q?<br>
&lt;Rossen_> ack emilio<br>
&lt;emilio> ack emilio<br>
&lt;fantasai> delan: Tab does have an interesting point though, that there's a general problem to be solved. Not sure<br>
&lt;fantasai> Rossen_: I'm a bit lost on where we're going from here. What would you like to see, delan?<br>
&lt;fantasai> delan: Leaving aside the more general issue of how we can use variables in non-element contexts<br>
&lt;fantasai> delan: for the core issue, I think consensus was that the best workaround so far is using custom property registrations with initial values<br>
&lt;emilio> having an `@root` or `@document {}` rule that applies to the whole document makes sense to me fwiw<br>
&lt;fantasai> delan: I guess the question I'm unsure about is do we think that is too annoying and unergonamic? No one had an opinion on that in the thread<br>
&lt;fantasai> delan: do we think that's already too annoying?<br>
&lt;fantasai> Rossen_: for developers?<br>
&lt;fantasai> delan: yeah<br>
&lt;argyle> q+<br>
&lt;emilio> q+<br>
&lt;fantasai> TabAtkins: Lea expresses that she find that's too unergonomic to be worthwhile and would prefer something else here<br>
&lt;Rossen_> ack argyle<br>
&lt;fantasai> argyle: I have lots of experience with custom properties, and it's very tedious to ...<br>
&lt;fantasai> argyle: I have a library called openprops with 350 properties<br>
&lt;TabAtkins> Also I'm not 100% sure off the top of my head how @property interacts with being nested in @media and @supports.<br>
&lt;fantasai> argyle: I'm not going to hand-author 300 @property rules so that they can drop into highlight pseudos<br>
&lt;fantasai> argyle: so some kind of higher level place to find these would be great<br>
&lt;fantasai> argyle: would be annoying to convert all my simple props and waiting for browsers to even support that<br>
&lt;Rossen_> ack emilio<br>
&lt;TabAtkins> (to be fair, both of these require waiting for support. but this is simpler than @property, yeah)<br>
&lt;fantasai> emilio: Mentioned on IRC, but having @document or @root or whatever to apply properties to the initial style makes a lot of sense<br>
&lt;Rossen_> ack fantasai<br>
&lt;emilio> fantasai: one advantage of inheriting from their originating element is that if you need to set variables deeper in the tree you can do that<br>
&lt;emilio> ... and then they'd behave as you expect, you might need to change your ::selection rules a bit<br>
&lt;fantasai> emilio: That was the thing I was thinking about. From an author's perspective, what you want is inheriting from originating element<br>
&lt;TabAtkins> I think we'd define @document in cascade?<br>
&lt;fantasai> emilio: Higher-level thing works for some cases, but might also be more confusing<br>
&lt;fantasai> Tab, but it wouldn't inherit that's the problem<br>
&lt;fantasai> Rossen_: Sounds like we need more discussion, suggest we take it back to the issue<br>
&lt;fantasai> Rossen_: maybe you all can start formalizing the various ideas, would be great<br>
&lt;argyle> 👍🏻<br>
&lt;fantasai> Rossen_: and maybe next time we can be closer to a resolution<br>
&lt;fantasai> delan: sounds good<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-1069356665 using your GitHub account


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

Received on Wednesday, 16 March 2022 17:09:44 UTC