W3C home > Mailing lists > Public > www-style@w3.org > March 2010

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

From: L. David Baron <dbaron@dbaron.org>
Date: Tue, 23 Mar 2010 16:50:48 -0400
To: "www-style@w3.org" <www-style@w3.org>
Message-ID: <20100323205048.GA32578@pickering.dbaron.org>
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


L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Tuesday, 23 March 2010 20:51:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:43 UTC