Csswg-drafts: [css-variables] should "--" be a valid custom property name?

Created on 22 May 2018  Â·  10Comments  Â·  Source: w3c/csswg-drafts

https://drafts.csswg.org/css-variables/#typedef-custom-property-name

The production corresponds to this: it’s defined as any valid identifier that starts with two dashes.

Shouldn't it be "any valid identifier that starts with two dashes and has a length greater than equal to 3"?

css-variables-1

All 10 comments

The production needs to stay as written - -- is intended to be a valid custom property name. That said, I intend to reserve -- as a variable-specific all, so I should probably put an additional restriction there. ^_^

Agenda+ to see if the group is okay with adding such a restriction, preventing authors from declaring a -- property (and reserving it for level 2 defining -- as a variable-specific version of all).

I’m fine with reserving it, but what situation is writing — better than just writing all? I assume you have something in mind?

In Edge -- is a valid custom property today, and it works fine in both declaration and usage.
Doesn't it in other browsers?

I should note it's valid but not special (it does not reset all the other custom properties)

I’m fine with reserving it, but what situation is writing -- better than just writing all? I assume you have something in mind?

When you're trying to prevent variables from inheriting into a component, but want to allow normal properties to inherit. (Without having to put in 100+ foo: inherit declarations.)

In Edge -- is a valid custom property today, and it works fine in both declaration and usage.
Doesn't it in other browsers?

Yes, thus the issue and Agenda+. It's currently valid and a perfectly normal property; I'm asking if we can restrict it (and then give it a special meaning).

Ah ok. Sure, I'm fine with this. It wouldn't be hard to do.

The Working Group just discussed should "--" be a valid custom property name?, and agreed to the following:

  • RESOLVED: Reserve -- for future use and it is not a valid custom property name

The full IRC log of that discussion
<dael> Topic: should "--" be a valid custom property name?

<dael> github: https://github.com/w3c/csswg-drafts/issues/2692

<dael> TabAtkins: Custom property names is anything starting with -- including -- by itself. I had intended to make a variable specific version of the all property and to claimm the -- name for it.

<dael> TabAtkins: Browsers allow -- as a custom property. I expect it's rare. I propose we officially disallow -- as a custom property name and add -- as an 'all' eq for variables

<AmeliaBR> Making -- an official part of the spec sounds kind of horrible, so I don't like that reason for disallowing author use!

<tantek_> +1 on TabAtkins proposal, seems reasonable

<dael> TabAtkins: Only compat is if someone is using a plain -- and I suspect most people don't even know it's valid.

<AmeliaBR> (But I'm still happy to disallow it for author use.)

<dael> astearns: Let's separate proposed future use from the current point of disallowing.

<tantek_> +1 on reserving it for possible future use that is

<dael> astearns: You ccan disagree with using -- with how TabAtkins has suggested and still be okay to disallow.

<dael> TabAtkins: I don't see why disallow if not using it for something in the future.

<dael> tantek_: [missed] disallow because it shows up in html with a meaning. It feels like it is throw away syntax rather then have meaning. To keep a bit of line noise out of stylesheets

<fantasai> +1 on reserving for possible future use from me as well

<dael> fremy: I wanted to say I reviewed and I'm fine with TabAtkins proposal. My PoV this is a good change

<tantek_> Let's resolve on just the first half. We can defer debating if it means anything in the future

<dael> astearns: Objections to reserve -- for future use?

<dael> RESOLVED: Reserve -- for future use and it is not a valid custom property name

For whenever it does come up in Variables 2, might I recommend all-- as the "variable-specific version of all".

All browsers I tried treat -- as a valid custom property name (I've tried Chrome, Firefox and Safari; Edge the same as mentioned above).
Since it works in most (all?) browsers with custom properties support, it can be already used somehow by authors. For example, it using in CSS Battle as a trick to minify size of CSS. I suppose CSS minifiers and other tools can util this technic as well.
It is likely that reserving -- will be useless.

Was this page helpful?
0 / 5 - 0 ratings