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

Re: [css-syntax] At-rules mixed in any declaration list?

From: Simon Sapin <simon.sapin@exyr.org>
Date: Mon, 20 May 2013 23:19:51 +0800
Message-ID: <519A3F17.30201@exyr.org>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: "www-style@w3.org" <www-style@w3.org>
Le 20/05/2013 07:48, Tab Atkins Jr. a écrit :
> On Sat, Apr 20, 2013 at 2:05 PM, Simon Sapin <simon.sapin@exyr.org> wrote:
>> Hi,
>>
>> Should any list of declarations also accept at-rules, like the body of @page
>> rules? This potentially affects style rules, style attribute, and various
>> at-rules. Even if no at-rules are recognized yet, it makes a difference in
>> where a new declaration starts:
>>
>> Parsed as unknown at-rule followed by a valid declaration:
>>
>>    @page {
>>      @margin-note { /* not supported */ }
>>      background: green;
>>    }
>>
>> In CSS 2.1, parsed as a single invalid declaration. The at-keyword instead
>> of the expected ident (property name) is an error; the parser recovers at
>> the next semi-colon:
>>
>>    body {
>>      @nested h1 { /* not supported */ }
>>      background: red;
>>    }
>>
>>
>> I think we should make that change for all lists of declarations and get the
>> error recovery in place, and not wait until we actually need it (eg. when/if
>> we want nested rules inside style rules.) CSS 2.1 did the same for @page: no
>> nested at-rule was defined yet, but the syntax still allowed them.
>
> I'm not sure exactly when I added this, and I don't want to go history
> trawling to find out, but the Syntax spec already handles at-rules in
> declaration lists appropriately.  When we finally define an at-rule
> meant to be nested inside a style rule, there won't be any problems on
> the core syntax side.

My point is that even we don’t define any such at-rule yet, this does 
make a detectable difference in error handling. It was important that 
CSS 2.1 defined @page that way, for example.

I’m in favor of doing this change and indeed Syntax 3 already has it. 
But I’d like the rest of the WG to be aware of this and resolve. If we 
do keep it, it needs to be listed in the Changes section.

Note that this is not only for style rules, but also style attributes 
and any at-rule that uses declaration syntax. (BTW, how do we update 
css-style-attr that’s in CR?)

Cheers,
-- 
Simon Sapin
Received on Monday, 20 May 2013 15:20:24 UTC

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