w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.52k stars 672 forks source link

[css-values] Proposal for an `all-vars` property to reset all custom properties #11105

Open miragecraft opened 4 weeks ago

miragecraft commented 4 weeks ago

As third party CSS can cause custom property name collisions, I propose a companion property to the existing all property that would allow us to reset all custom properties.

I'm tentatively naming it all-vars.

Loirooriol commented 4 weeks ago

There was an idea to use -- for that, see https://github.com/w3c/csswg-drafts/issues/6313#issuecomment-854844912

miragecraft commented 4 weeks ago

I prefer all-vars personally as -- reads like a syntax error to me, plus it breaks from the tradition of CSS properties spelling out what they’re for.

At the end of the day I just want to have a way to reset all custom properties, if everyone prefers -- I have no objections.

fantasai commented 4 weeks ago

If there's no compat against it, could use --all to be more explicit.

Loirooriol commented 4 weeks ago

As an author I want to be able to use --whatever without fearing that it won't be forwards compatible because CSS will reserve it in the future.

Among the things starting with 2 hyphens, we only reserved --, so I think we should go with that, if any.

bleper commented 4 weeks ago

Another approach is to introduce a keyword into the all property to extend its coverage to custom properties, or to introduce an all-behavior property and put the keyword there, similar to transition-behavior, to allow later inclusion of properties excluded today or in the future.

miragecraft commented 4 weeks ago

Another approach is to introduce a keyword into the all property to extend its coverage to custom properties, or to introduce an all-behavior property and put the keyword there, similar to transition-behavior, to allow later inclusion of properties excluded today or in the future.

That approach forces you to use the same value for both regular properties and custom properties.

With a dedicated property, you are able to specify all:unset; all-vars:revert-layer.

Loirooriol commented 4 weeks ago

Note that all is a shorthand (at least according to the spec, but Blink isn't compliant). I don't think this can be a shorthand because shorthands need to expand at parse time, but there is an infinite number of possible custom properties. So I wouldn't mix this with all.

to allow later inclusion of properties excluded today or in the future

As long as all is a shorthand this is not possible, because the value of transition-behavior isn't known until computed value time, but we need to expand shorthands earlier in the cascade.