W3C home > Mailing lists > Public > www-style@w3.org > January 2008

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

From: Justin Rogers <justrog@microsoft.com>
Date: Sun, 27 Jan 2008 13:40:24 -0800
To: Brad Kemper <brkemper@comcast.net>, "www-style@w3.org Style" <www-style@w3.org>
Message-ID: <00BD06E707F60B4F9D6A3E75C712209D49A94E5E41@NA-EXMSG-C104.redmond.corp.microsoft.com>
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.

For the last production rule (I'll copy here)
   @1 { [ }
            div { color:green;}

FireFox is correct. The first } does not close the block because the current open scope is a bracket, not a brace. Adding a bracket after the closing brace doesn't help because the following rule should still be eaten since we haven't closed our block yet. I'll demonstrate here

@1 starts error recovery for selectors
{ opens a block of type brace
[ opens a block of type bracket
} invalid token
div { color: green; } /* all still in error recovery. Our top of the token stack is a bracket which we haven't matched */

Adding a bracket after the closing brace closes the bracket scope, but still does not satisfy the brace scope. The final } in the file after color: green; is where we finally close the scope and error recovery is complete. This means the following file should work:

   @1 { [ } ]
            div { color:green;}
                div  { color: green; } /* The last rule eaten was the first div selector above, while I'm safe */

For Brad in regards to IE... I would ask that IE be left out of syntax discussions for now, since the legacy behavior would likely be an impediment to moving forwards. Further, the error recovery is designed around common mistakes people made and not so much around the error recovery as detailed by the spec. Most of which comes from shipping the parser before the spec was complete in most cases and then having to continue to support the bad syntax moving forward.


From: Brad Kemper [mailto:brkemper@comcast.net]
Sent: Sunday, January 27, 2008 1:15 PM
To: www-style@w3.org Style
Cc: Justin Rogers
Subject: Re: [CSS 2.1] General at-blocks and error recovery

On Jan 27, 2008, at 12:18 PM, Brad Kemper wrote:

On Jan 26, 2008, at 8:20 PM, Justin Rogers wrote:

DIV { color: green; }

Then you would expect the DIV rule to get thrown out. However, if you treat @1 like an actual at rule, then you could technically start your reparse at the semi-colon. Browsers again disagree with FireFox/Opera eating the entire declaration while Safari is perfectly happy going into at rule error recovery instead.

It looks to me as though Opera (9.25 on Mac OS X) is also applying the rule.

In fact, here is what I found...

green in Safari and Opera (not FireFox):
   @1; div { color:green; }
   @1 []; div { color:green; }

green in Opera only:
   @1 [{}]; div { color:green; }

green in Opera only (with ALL subsequent rules seemingly ignored in Safari and FireFox):
@media all {
div { color:green; }

green in Opera and Safari (with ALL subsequent rules seemingly ignored in FireFox):
   @1 { [ }
            div { color:green;}

on this last one, adding a "]" or ";"  anywhere after the first "}" does not seem to help FireFox recover.

I should mention that this is with FireFox 3.0b2, and a nightly download of Webkit, 3.0.4 (523.12.2). I don't have IE handy here, so I don't know how it responds.
Received on Sunday, 27 January 2008 21:40:41 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:33 UTC