Re: [css3-selectors] :nth-child issues

Tab Atkins Jr. wrote:
> The relevant text from css3-selectors:
> 
> The :nth-child(an+b) pseudo-class notation represents an element that
> has an+b-1 siblings before it in the document tree, for a given
> positive integer or zero value of n, and has a parent element. In
> other words, this matches the bth child of an element after all the
> children have been split into groups of a elements each. For example,
> this allows the selectors to address every other row in a table, and
> could be used to alternate the color of paragraph text in a cycle of
> four. The a and b values must be zero, negative integers or positive
> integers. The index of the first child of an element is 1.
> 
> We noticed two possibles issues in the chatroom today.
> 
> First, the prose says an+b matches "the bth child of an element after
> all the children have been split into groups of a elements each".
> This doesn't work correctly when b=0, as there is either no bth-child
> (if we assume that the later sentence about 1-numbering is to be taken
> here as well), or it specifies the wrong elements (if we assume
> 0-numbering).

This sentence has already been reworded in response to Anton Prowse's
LC comments. Please take a look at the Editor's Draft and let me know
if your concern has been addressed.
   http://dev.w3.org/csswg/selectors3/#nth-child-pseudo

> Second, what should happen when a and b are both 0?  This matches no
> elements, since it evaluates to 0 and the first element is 1.
> However, Opera drops the rule entirely, rather than keeping it around
> as a rule that simply matches nothing.

I agree with dbaron's response:
   http://lists.w3.org/Archives/Public/www-style/2009Oct/0210.html
   http://lists.w3.org/Archives/Public/www-style/2009Oct/0211.html

~fantasai

Received on Tuesday, 20 October 2009 19:36:04 UTC