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

Re: [selectors] Matching of :first-child and the like for elements whose parent is not an element

From: Simon Sapin <simon.sapin@exyr.org>
Date: Mon, 18 Mar 2013 20:18:31 +0100
Message-ID: <51476887.5010002@exyr.org>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: www-style list <www-style@w3.org>
Le 18/03/2013 19:48, Boris Zbarsky a écrit :
> The selectors spec says, at
> http://dev.w3.org/csswg/selectors4/#the-first-child-pseudo  :
>     The :first-child pseudo-class represents an element that is the first
>     child of some other element.
> and similar for other structural pseudo-classes.
> On the face of it that means such selectors never match root elements or
> children of document fragments.
> Is this restriction purposeful?  It seems like sane structural
> pseudo-class matching (e.g. nth-of-type) might be desirable with
> querySelector on DocumentFragment at the very least...

It seems to be on purpose, yes.

:first-child is "Same as :nth-child(1)", and :nth-child(an+b) 
"represents an element that has an+b-1 siblings […], **and has a parent 

(emphasis added.)

I personally don’t really care either way, but it’s been explicitly 
defined that way for a long time…

Simon Sapin
Received on Monday, 18 March 2013 19:19:00 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:09 UTC