Re: [selectors] Child-indexed pseudo-classes and the root element

There was quite a bit of discussion already, see:

  https://github.com/w3c/csswg-drafts/issues/695

Note that the L3 definition was in terms of parent _elements_, and that
didn't play very well with shadow DOM. See also the blink-dev discussion:


https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/RgdSWmv0s4g

On 09/06/2017 06:51 AM, Daniel Tan wrote:
> I noticed that :root:nth-child(n) now matches in Chrome and Firefox. It
> does not match in Safari, IE or Edge, as I would expect. It seems that
> this was changed in selectors-4, which says
> 
>> Note: Selectors 3 described these selectors as selecting elements
>> based on their index in the child list of their parents. (This
>> description survives in the name of this very section, and the names
>> of several of the pseudo-classes.) As there was no reason to exclude
>> them from matching elements without parents, or with non-element
>> parents, they have been rephrased to refer to an element’s relative
>> index amongst its siblings.
> 
> The definition of "inclusive siblings" points to the DOM spec, which
> requires that an element have a non-null parent in order to be
> considered a sibling:
> 
>> An inclusive sibling is an object or one of its siblings.

Well, this definition seems like it would match "an object" itself,
regardless of the parent node required to be a "sibling", so I don't
think there's any inconsistency here.

Regardless of that, the root element's parent node is non-null anyway
(the parent node is the document node). This boils down again to parent
element vs. parent node.

 -- Emilio

Received on Wednesday, 6 September 2017 09:14:24 UTC