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

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].

Use:
> 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.

Use:
> 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