Custom CSS properties are so ugly with those leading dashes!


When introducing CSS variables (custom properties), you advertised them as a way for polyfilling. Polyfilling a CSS property naturally involves determining what elements have that property.

in a better way

Better than what?


I seriously can’t tell if you’re trolling or if you haven’t read the spec I pointed to or what.


As I said, I’ve read the spec. And I don’t see how it helps in terms of polyfilling other than just allowing custom properties to have an initial value and to be non-inherited.

Say we are going to polyfill a new property --foo that should serve for a new layout mechanism. Seriously, how could a web developer know what elements have the property (other than by enumerating all elements in the document one by one)?

If I’ve missed an essential relevant part of the spec, could you be [more] specific (instead of being abstract or, all the more, using unhelpful offensive inappropriate buzzwords like trolling) on what exact part of the spec allows to add desired polyfilled behavior to elements that have the property (not just make the property having an initial value and desired inheritance)?

I suspect you mean some different spec. o_O

(If you still don’t understand what I’m asking, please send a private message to request additional clarification.)


Ah, I see the problem - I forgot that we pushed the apply hook to level 2 Sorry about that! That’s how we handle actually giving custom properties special behavior.


Where can it be viewed in a directly readable form?


It’s not built anywhere, but if you send the source through the online processor you’ll get HTML back out.


I see! I was asking more for a practical example. I guess I can imagine one: suppose we want to change everything that has a red border to have a blue border. Selecting all elements that have border-color: red; would make it very easy to then change them all to blue. That would be easier than dealing with the CSS cascade because we could apply the color directly to each element, which would automatically put the new style at the end of the cascade (i.e. give it the highest specificity).

I think this might be a good reason to be able to select-by-property and make massive changes all at once. But, it’d also present encapsulation issues. I suppose ShadowDOM can be explicitly used by someone who wants to guard against unwanted changes (and optionally expose very specific properties (like --my-framework-some-color) to make it really explicit what things can be modified at large.

I think that’s a good idea (and balances out with ShadowDOM).