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

fantasai wrote:
> Tab Atkins Jr. wrote:
>> 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

Agreed.

I don't think there's a spec problem here, since the sentence

   # The :nth-child(an+b) pseudo-class notation represents an element
   # that has an+b-1 siblings before it in the document tree, for any
   # positive integer or zero value of n, and has a parent element.

(which is a bit odd in the case where an+b is non-positive) is further
qualified lower down by the explicit

   # If both a and b are equal to zero, the pseudo-class represents no
   # element in the document tree.


However, closer inspection does reveal another issue:  it's not clear to
me in this section whether "-0" is a permitted value of a.  If it is, then

   # The a and b values must be integers (positive, negative, or zero)

is, pedantically speaking, incorrect since "-0" is not an integer; and
more importantly, from the following:

   # When a=0, the an part need not be included (unless the b part is
   # already omitted).

   # If b=0, then every ath element is picked. In such a case, the +b (or
   # -b) part may be omitted unless the a part is already omitted.

we see that all simplifications of :nth-child(an+b) where each of a and
b is one of 0 and -0 are accounted for, apart from the simplification of
:nth-child(-0n+0) and nth-child(-0n-0) to nth-child(0).

The first quoted sentence above should be changed to:

   | When a=0 or a=-0, the ab part need not be included (unless the b
   | part is already omitted).


Also, the following example appears /before/ the discussion of b=0:

   # Examples:
   #
   # The following selectors are therefore equivalent:
   #
   #   bar:nth-child(1n+0)   /* represents all bar elements, specificity
   #                            (0,1,1) */
   #   bar:nth-child(n+0)    /* same */
   #   bar:nth-child(n)      /* same */
   #   bar                   /* same but lower specificity (0,0,1) */

but should really be moved after it (perhaps even after the subsequent
example).


Cheers,
Anton Prowse
http://dev.moonhenge.net

Received on Tuesday, 20 October 2009 21:06:44 UTC