Re: Malformed declarations incorrectly parsed?

Yves Lafon wrote:
> On Tue, 18 Mar 2008, Benjamin Hawkes-Lewis wrote:
> 
>> Hmm. I tried this with the very same example and it still extracts:
>>
>> p {
>> color : red;
>> color : green;
>> }
>>
>> Does that not happen for you?
> 
> Yes, but it's normal.
> The spec says that it is "equivalent"  to p { color: green } and it is, 
> because of the cascading rules. If you turn the warnings on, you will 
> have a "redefinition warning" in that case, and in the end, it is 
> equivalent to p { color: green }.

Sorry, but I think you've missed the point of the test case:

p { color:red; color:; color:green }

The problem is not that the validator reports a redefinition of color. 
The problem is that if you apply the rule:

"Lexical errors are handled with a skip to matching brace"

Then the validator should skip to the matching brace after "color:;", 
since that is a "lexical error". It should not report any declarations 
after "color:;" at all, whether they are redefinitions or not.

Perhaps a new test case will make the point clearer:

p { font-weight:bold; color:; text-decoration:underline }

Here the development version of the validator reports:

> Value Error : color Parse Error :

But it goes on to extract the following "valid" CSS information:

> p {
> font-weight : bold;
> text-decoration : underline;
> }

In other words, far from skipping to a matching brace after the lexical 
error "color:;", it moves onto the next declaration in the block 
("text-decoration:underline"). This is entirely consistent with the 
spec's error-recovery rules, and entirely inconsistent with the 
undocumented "skip to matching brace" error recovery you say you're 
trying to implement. If it skipped to the matching brace, it would 
report instead:

p {
font-weight: bold;
}

--
Benjamin Hawkes-Lewis

Received on Wednesday, 19 March 2008 08:44:57 UTC