Re: [css3-selectors] :nth-child() argument and comments

On Thursday 2010-03-18 16:06 +0100, Daniel Glazman wrote:
> One of "Microsoft tests" for IE9 tests comments inside :nth-child()
> 
> 
> http://samples.msdn.microsoft.com/ietestcenter/css3/selectors/ValidComments.htm
> 
> Some of the already existing implementations fail on this because
> we always discussed an argument "2n+1" tokenized as a "2n" dimension
> and a "+1" number here. We never thought of comments "à la"
> 
>   2/*this is a comment/*n+1
> 
> and they probably don't make sense at all, even from a web author's
> point of view. We need a clarification in the Selectors spec here, to
> say if comments are forbidden inside the argument of :nth-child() and
> allowed only around it, or allowed everywhere inside.
> 
> I am myself *strongly* in favor of the former, and I understand that
> would make the test linked above invalid.

I think the general precedent in CSS has been that comments are
allowed anywhere between tokens.  (It's not a very good strategy for
building an object model that contains comments, which is required
for editing, but it's the one we have.)  That's actually somewhat
hard-coded into our tokenizer.

I think Gecko allows comments in other places inside :nth-child(),
(including everywhere that whitespace is allowed) but not in the one
above, since we only accept the '2n' as a dimension token (though we
could change that).

I'm a little bit uncomfortable disallowing comments in places where
we allow whitespace.


It's probably somewhat easier for us to switch for allowing comments
in more places (i.e., accepting the example above) than to switch to
allowing them in fewer, but it's probably doable with some amount of
work.

-David

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

Received on Tuesday, 23 March 2010 20:51:17 UTC