Re: [css3-conditional] @supports API

To me, it seems like any error should be handled by having the API return 
false. Are there any case where you would prefer doing otherwhise? The main 
problem may rather be: How simple is it to catch all CSS errors with a 
parser that has been made to overcome any error, and not especially 
"throwing" or "notifying" about them.



-----Message d'origine----- 
From: L. David Baron
Sent: Tuesday, October 11, 2011 9:32 PM
To: FrançoisREMY
Cc: Peter Beverloo ; Paul Irish ; www-style@w3.org
Subject: Re: [css3-conditional] @supports API

On Tuesday 2011-10-11 20:48 +0200, François REMY wrote:
> Just a question: wouldn't it better to have a "full parser" that can
> recognize any piece valid CSS ?
>
> window.recognizeCSS("x::scrollbar {}"); // false
> window.recognizeCSS("* { width: 1px; }"); // true
> window.recognizeCSS("* { -unknown-property: 3 }"); // false

The problem with that approach is that a full parser has rules for
ignoring invalid things at certain points:  for example, while
parsing a rule, invalid declarations are dropped; while parsing the
top level of a style sheet, invalid rules are dropped.  (There are
further rules for media queries and for handling of errors inside
various types of @-rules.)

With an API like this, it's not clear which errors are handled by
dropping (as per the normal parsing rules) and which are handled by
having the API return false.

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                           http://www.mozilla.org/   𝄂 

Received on Tuesday, 11 October 2011 19:43:33 UTC