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

On Sat, Mar 15, 2014 at 1:54 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> On 16/03/2014 3:28 am, Tab Atkins Jr. wrote:
>> No, we don't currently have that in any context, nor are there any
>> current plans for such.  It would be *extremely* weird, since we don't
>> use -foo in the core language at all, and so any case where a "-" can
>> be put next to an ident-like token *already* requires a space between
>> them, to avoid the "-" being interpreted as part of the ident.
>>
>> I'm potentially open to tweaking Syntax here (the fact that it's in CR
>> is just a Process sop; we can continue to change as
>> prudent/necessary), but as Simon says, this is a larger change than
>> just switching the naming pattern from one valid ident to another.
>> I'll leave it to heycam to decide whether this is something that's
>> possible to do within their shipping deadline or not.
>
> I don't forsee "--" as needing any changes to our CSS parser, so it
> shouldn't be any harder to switch to than "_".
>
> Despite Brian's retraction of the suggestion, I think using "--" is
> preferable to "_", on visual aesthetic grounds.

Excellent, then.  I also prefer the aesthetics (not to mention
typeability) of --, so let's consider that the official front-runner.

> I also think it should
> be required as a prefix, not just a substring anywhere.  That has the
> advantage of being easier to check in the parser, as well as enforcing
> some uniformity.

I'm fine with that.

>   p {
>     --company-color-1: green;
>     background-color: var(company-color-1);
>   }
>
> looks fine to me.  Underscores look very un-CSS-like.

That's why I reached for them - they were valid, but CSS wasn't
planning on using them. ^_^  But yeah, -- as a prefix works just fine
for me - it's easy to type, easy to see/notice, has a nice parallel
with the old vendor prefixes, and as a special bonus, simplifies the
definition of <ident-token> slightly.  Seems like a big win over using
_, yay!

> I don't have too much of an opinion on whether we should change custom
> property names from a "var-" prefix, but it does make sense to consider
> it, to align with the naming of other (future) custom things in CSS.

I'm very happy to use -- in the other new custom things, too: "@media
(--foo) {...}" looks just fine to me, as does "div:--bar {...}".

~TJ

Received on Saturday, 15 March 2014 23:50:38 UTC