- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Fri, 27 Apr 2012 09:22:58 -0700
- To: Vasily Stepanov <vasily.stepanov@gmail.com>
- Cc: www-style@w3.org
On Fri, Apr 27, 2012 at 1:49 AM, Vasily Stepanov <vasily.stepanov@gmail.com> wrote: > According to error handling, described in section 3.1: > User agents are to handle unexpected tokens encountered while parsing > a media query by reading until the end of the media query, while > observing the rules for matching pairs of (), [], {}, "", and '', and > correctly handling escapes. > There is an example for this case: > @media (example, all,), speech { /* only applicable to speech devices */ } > > CSS21 says the following in section 4.1.5: An at-rule consists of > everything up to and including the next semicolon (;) or the next > block, whichever comes first. > > Consider this malformed CSS example: > @media {example, all,}, speech { /* only applicable to speech devices */ } > > () block from the previous example has been replaced with {} block. > > So it is unclear how should I parse this malformed CSS. > > According to CSS21 I have to parse it like this: > @media { /* error while parsing rulesets */ } > /* error while parsing selectors */ > > According to css3-mediaqueries I have to parse it like this: > @media /* error while parsing media query */ speech { /* ... */ } Simon is correct in both his examples - your "CSS21" interpretation is the right behavior. I agree that this isn't perfectly clear from the MQ spec - a basic disadvantage of relying purely on grammar-based error handling. This will be tightened up in the future by the Syntax module. The parser shouldn't attempt to validate the @media rule until it has been closed, which happens after the first } in your example. The stuff following that first } will parse as a Rule instead, with a selector of ", speech", and thus will also be ignored. ~TJ
Received on Friday, 27 April 2012 16:23:48 UTC