Re: [CSS 2.1] General at-blocks and error recovery

On Saturday 2008-03-08 10:54 +0100, Anne van Kesteren wrote:
> On Sat, 08 Mar 2008 06:56:11 +0100, L. David Baron <dbaron@dbaron.org> 
> wrote:
>> What Firefox is doing is the following:
>>
>> @media all {
>>   /* ok, we're inside an @media rule, so we parse declaration blocks */
>> @
>>   /* well, this is the beginning of an invalid selector, so we have
>>      to parse until we hit the end of the declaration block, that
>>      is, until we hit an { and then the matching } */
>> }
>>   /* not a {, so keep looking for the { to start our declaration block */
>>   /* ... same for all remaining tokens in the style sheet */
>>
>> I can't find anything that says what @media rules are supposed to
>> have in them, but this seems to match the spec, now that I think
>> about it.
>
> I figured this was the reasoning. So is the reason this does not violate
>
>   http://www.w3.org/TR/CSS21/syndata.html#block
>
> that you're trying to form an at-rule token and therefore the matching { } 
> pair is not actually a matching pair but the closing curly brace is part of 
> a token?

No, it's definitely not part of a token.  The tokenizer is quite
clear.

What's happening is that after the "@" we're parsing an invalid
selector.  When we're parsing an invalid selector, we recover after
we find a "{" and then a matching "}" (a declaration block).  When
we hit the "{", we're looking for a "{" so it doesn't actually match
anything.

If you want Firefox to recover after "@media all { @ }" it will if
you write "{ } }".  The "{ }" is the declaration block it's looking
for, and the final "}" closes the @media rule.

-David

-- 
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/

Received on Saturday, 8 March 2008 16:25:25 UTC