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

On Friday 2008-03-07 21:18 -0800, L. David Baron wrote:
> On Sunday 2008-01-27 13:14 -0800, Brad Kemper wrote:
> > green in Opera only (with ALL subsequent rules seemingly ignored in Safari 
> > and FireFox):
> > @media all {
> >    @
> > }
> > div { color:green; }
> 
> I think this one should produce green; this seems like a bug in
> Firefox.

> On Sunday 2008-01-27 13:40 -0800, Justin Rogers wrote:
> > The @media production rule brings up another question. I read it as:
> > 
> > -- Most interesting of Brad's additional test cases
> > @media all { /* open scope +1 */
> >   @ /* invalid token, go into selector error recovery which looks for a block */
> > } /* close scope from @media */
> > 
> > Because of the last scope closure, it ends the error recovery
> > started at the invalid @ symbol (read as IMHO I think it should
> > end the error recovery since others can certainly beg to differ).
> > All subsequent rules after it should be parsed normally so I would
> > say the DIV should be green.
> 
> Agreed.  I think it's a bug in Firefox that it needs a {} to recover
> from a stray @ inside an @media rule.

Actually, I'm not so sure here.

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.

-David

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

Received on Saturday, 8 March 2008 05:56:44 UTC