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

On Tuesday 2009-10-20 09:57 -0500, 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).

I think the best thing to do here is either remove the sentence that
begins with "In other words" or reword it to be an example.

> 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.

The spec doesn't say to drop the rule, so it's just a rule that
matches no elements, just like p:not(p).

-David

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

Received on Tuesday, 20 October 2009 15:19:42 UTC