W3C home > Mailing lists > Public > www-style@w3.org > March 2013

Re: [css-variables] Comments on WD-css-variables-20130312

From: Simon Sapin <simon.sapin@exyr.org>
Date: Sat, 30 Mar 2013 11:53:05 +0100
Message-ID: <5156C411.8040702@exyr.org>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: Bjoern Hoehrmann <derhoermi@gmx.net>, www-style list <www-style@w3.org>
Le 30/03/2013 00:30, Tab Atkins Jr. a écrit :
>> The reference to <ident> is misleading, the author-
>> defined part of the name would not be a token on its own; say something
>> like 'A custom property is any property whose name starts with "var-"'
>> instead.
> Nope, the part after "var-" needs to conform to the <ident> grammar,
> so you can use it as a bare value in the var() function.

Does it really? What matters is that the parsed value of the identifiers 
match, right? It shouldn’t matter if they use different escaping.

For example, var-1st is a valid property name, but 1st is not an 
<ident>. You can still write an ident with the same parsed value by 
escaping the digit: var(\31st)

Sure, we might recommend to authors not to do that because it’s ugly. 
But there is no reason to require UAs to disallow it.

Actually, detecting var-1st vs. var-\31st would require a special case 
in the tokenizer. We did that for ID selectors for legacy reasons[1], 
but let’s not repeat that pattern.

So I suggest:

1. Instead of:
> A custom property is any property whose name starts with "var-", and
> the rest of the name conforms to the grammar for an identifier
> [CSS3VAL].

> A custom property is any property whose name starts with "var-", and
> contains at least one more character.

2. Instead of:
> The part of the custom property name after the "var-" must be an
> identifier by itself. This means that, for example, ‘var-0’ is not a
> valid custom property name, because ‘0’ isn't a valid identifier.

> Authors are recommended to choose custom property names so that the
> part after the "var-" is an identifier by itself, so that it can be
> referenced without <a
> href="http://www.w3.org/TR/CSS21/syndata.html#escaped-characters">character
> escaping</a>. For example, ‘var-0’ needs to be referenced as
> var(\30), because ‘0’ isn't a valid identifier. (U+0030 is the hexadecimal
> code for the ‘0’ character.)

By the way, although it’s obvious from the examples I don’t see 
specified that the variable name used in var() is the name of the custom 
property without the var- prefix.

[1] I think allowing any hash tokens to be ID selectors in a new 
language would be just fine. It just has been specified and implemented 
as # plus <ident> since forever, and changing it now is not worth the 
potential risk of "breaking the web".

Simon Sapin
Received on Saturday, 30 March 2013 10:53:31 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:27 UTC