[css-variables] ...let's change the syntax

I've been thinking.

At the last f2f, I proposed custom MQs and pseudo-classes.  To
distinguish them from CSS-defined ones, I mandated that they had to
start with (or perhaps just contain) an underscore character, because
this is a valid character that CSS is nevertheless never going to use
in language-defined names.

This, while a little ugly, seems to do the job pretty well.

Simultaneously, I'm wrestling with the fact that basically nobody
understands that one of the primary use-cases of Custom Properties is
to do CSS polyfills, where you write your own properties with a "var-"
prefix and interpret them with JS.  This avoids the "have to re-parse
the whole stylesheet yourself, and woe unto you if it's cross-origin"
problem that today's CSS polyfills have.  From what I can tell, it's
the "var-" prefix that's misleading everyone - it's *so* closely tied
to var(), mentally, that it prevents people from imagining any other
use.

Given that "tie it to var()" was one of my explicit justifications for
sticking with the "var-" prefix, I'm very aware of how much I've
hoisted myself by my own petard.

So, suggestion.  Assuming that we're sticking with the underscore
thing for custom MQs/pseudo-classes/etc, I think we should move the
syntax of Custom Properties to "any ident starting with/containing an
underscore" as well.  This'll tie the syntax more closely to the
*other* "custom" things, which hopefully will lead to it being more
obvious that this is literally a CUSTOM PROPERTY, not just a variable
definition.

The var() syntax is unchanged - the argument just switches to being
literally the property name, rather than the property name minus the
prefix.

I talked to heycam about this a few hours ago, and he said that
Firefox is ready to ship Variables Real Soon Now, but this is a minor
enough change that it can be swapped in real quick and not delay
shipping if we decide on it quickly.

I've given myself a self-imposed deadline of until the next conf call
to decide on this; if we say nay, or just don't decide, I'll happily
stick with what's currently in the draft, and let Firefox ship with
it.  However, I'd like to spend the next week deciding whether we
should change the spec on this or not.

Thoughts?

~TJ

Received on Thursday, 13 March 2014 03:39:17 UTC