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

On Mon, Mar 18, 2013 at 11:48 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> 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...

fantasai says this was indeed purposeful, and letting them match the
root doesn't really buy you anything in a normal document, but your
documentFragment usecase is compelling.

I think we should change to at least allow it in that case.  I suspect
it's compat-friendly to allow it to match a normal root as well.

~TJ

Received on Monday, 18 March 2013 19:26:54 UTC