Malformed declarations incorrectly parsed?

The CSS 2.1 spec defines some rules for parsing malformed declarations:

http://www.w3.org/TR/CSS21/syndata.html#parsing-errors

Based on the two CSS grammars and these rules, I would expect that given 
the input:

h1 {color: red;}
p {font-weight: bold; width: 100em !ie; color: green;}
em {color: yellow;}

the validator would extract the following CSS:

h1 {
color: red;
}
p {
font-weight: bold;
color : green;
}
em {
color: yellow;
}

since while width: 100em !ie cannot be tokenized as a CSS 2.1 
declaration, I think it can be tokenized with the core CSS grammar like 
this:

(ruleset: (selector: (ident: p) (whitespace) )  ('{') (declaration: 
(property: width) (whitespace) (':') (value: (dimension: 100em) 
(whitespace) (delim: !) (ident: ie) ) )  ('}') )

However, the validator drops the entire ruleset, extracting only:

h1 {
color: red;
}
em {
color: yellow;
}

I noticed that the validator doesn't handle some of the examples of 
malformed declarations given in the spec correctly.

(a) p { color:red;   color; color:green }


(a) p { color:green; color{;color:maroon} }

(c) p { color:red;   color{;color:maroon}; color:green }

The validator should have extracted color: red; in (a) and (c) and 
color: green; in (a), (b), and (c), but in fact it extracts no valid CSS 
information.

Can anyone confirm if this reflects a bug in the validator?

--
Benjamin Hawkes-Lewis

Received on Friday, 14 March 2008 07:41:07 UTC