Re: [CSS2.1] Any hope of fixing HASH #{name} to disallow numeric identifiers?

On Friday 2008-01-18 17:11 -0800, Justin Rogers wrote:
> While going through the W3 CSS validator something along the lines of:
> 
> #4 { color: green; }
> 
> Doesn't pass with a cryptic error message about CSS1 and CSS2
> rules for identifiers, but has no mention of CSS2.1. The CSS2.1
> "sample" grammar allows for {name} to be {nmchar}+, which
> specifically allows digits. A failure when parsing means error
> recovery as opposed to a rule that might never match (for
> instance, if #4 is an allowed selector, but is a disallowed id in
> the document language is much different from #4 being a syntax
> error). If we truly support only support {ident} then we should
> change this stuff over so it is obvious the errant use of a
> numeric value will cause.
> 
> It is quite obvious that browsers support {ident} here and not
> {name}. FireFox will throw out the rules for {name} and won't even
> show them in the OM. They'll allow rules such as:

There are plenty of constraints in the spec that are parse-time
errors but aren't expressed in the grammar.  If the validator's
message is confusing or incorrect, that may well be a bug in the
validator (which is definitely *not* a reference implementation).

The token in the formal syntax (both the one in Chapter 4 and the
one in Appendix G) needs to allow initial numbers for color values
(where they are allowed), but they're not allowed in ID selectors.

The current state of the spec *should* be that #4 as an ID selector
is a syntax error, but it's not the formal grammar that says so but
rather the prose in the selectors chapter (combined with the
statement in 4.1.7 that "When a user agent can't parse the selector
(i.e., it is not valid CSS 2.1), it must ignore the declaration
block as well.").

-David

-- 
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/

Received on Saturday, 19 January 2008 01:36:53 UTC