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

Re: [css-variables] Syntax of custom property declarations

From: Simon Sapin <simon.sapin@exyr.org>
Date: Mon, 20 May 2013 23:01:12 +0800
Message-ID: <519A3AB8.80900@exyr.org>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: "www-style@w3.org" <www-style@w3.org>
Le 20/05/2013 07:52, Tab Atkins Jr. a écrit :
> On Sun, Apr 14, 2013 at 7:00 AM, Simon Sapin <simon.sapin@exyr.org> wrote:
>> Hi,
>>
>> The "Values" line for custom properties is defined as:
>>
>>    [ <value> | <CDO> | <CDC> ]+
>>
>> Where <value> is defined in the CSS 2.1 core grammar:
>>
>>> stylesheet  : [ CDO | CDC | S | statement ]*;
>>> statement   : ruleset | at-rule;
>>> at-rule     : ATKEYWORD S* any* [ block | ';' S* ];
>>> block       : '{' S* [ any | block | ATKEYWORD S* | ';' S* ]* '}' S*;
>>> ruleset     : selector? '{' S* declaration? [ ';' S* declaration? ]* '}'
>>> S*;
>>> selector    : any+;
>>> declaration : property S* ':' S* value;
>>> property    : IDENT;
>>> value       : [ any | block | ATKEYWORD S* ]+;
>>> any         : [ IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING
>>>                | DELIM | URI | HASH | UNICODE-RANGE | INCLUDES
>>>                | DASHMATCH | ':' | FUNCTION S* [any|unused]* ')'
>>>                | '(' S* [any|unused]* ')' | '[' S* [any|unused]* ']'
>>>                ] S*;
>>> unused      : block | ATKEYWORD S* | ';' S* | CDO S* | CDC S*;
>>>
>>> The "unused" production is not used in CSS and will not be used by
>>> any future extension. It is included here only to help with error
>>> handling.
>>
>>
>> I’m a bit confused as to what this means exactly. Is <declaration> extended
>> to allow CDO and CDC? Is <unused> allowed in spite of being … "not used"?
>> Are CDO and CDC allowed inside a {} block? Is a declaration-level ';' token
>> allowed?
>>
>>      var-foo: <!-- bar -->;
>>      var-foo: [@bar];
>>      var-foo: [{}];
>>      var-foo: [;];
>>      @supports (var-foo: bar;baz) {}
>>      var-foo: [<!-- bar -->];
>>      var-foo: {<!-- bar -->};
>>      var-foo: /* unmatched */ )]};
>>      var-foo: url("bar" bad url);
>>      var-foo: bar "Bad string: unquoted newline
>>        ;
>>      var-foo: bar /* Bad comment not closed until EOF
>>
>> Even if such corner cases would never be valid in a "real" property through
>> var(), they make a difference in which custom properties are available
>> through CSSStyleDeclaration.
>>
>> I’d be more comfortable with a negative definition. Something like: "any
>> sequence of tokens except BAD_STRING, BAD_URL, BAD_COMMENT[1], unmatched
>> ')', unmatched ']', and unmatched '}'."
>>
>> [1] Not sure about BAD_COMMENT as Syntax 3 makes all comments valid, even
>> unclosed.
>>
>> A definition based on Syntax 3 (which defines precisely how any character
>> sequence is parsed into a tree of "component values") would be even better,
>> but I understand that Syntax 3 might not be mature enough to be referenced
>> from Variables which we want to progress fast.
>>
>> I’m not asking for a change here, only clarification. I hope this will not
>> delay the spec going to LC and CR.
>
> A Syntax-based definition of the value is simply "(anything, see
> prose)", with the prose informatively explaining some of the implicit
> restrictions that arise from the parser.
>
> I'd be fine with switching over to that as soon as Syntax is approved
> for FPWD (hopefully at the f2f).

This is independent of the advancement of Syntax 3, I just find the 
Syntax 3 terminology more precise and convenient.

I was under the impression that at least BAD_STRING and BAD_URL tokens 
were excluded from custom properties and would make the declaration invalid.

We could drop declarations containing "invalid tokens" (however we 
define this) at the Syntax level, but currently the ED does nothing of 
the sort.

Candidates for "invalidity": bad-string, bad-url, unmatched }]), maybe 
cdo and cdc.

-- 
Simon Sapin
Received on Monday, 20 May 2013 15:01:40 UTC

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