W3C home > Mailing lists > Public > www-style@w3.org > September 2017

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

From: Daniel Tan <lists@novalistic.com>
Date: Wed, 6 Sep 2017 12:51:32 +0800
To: www-style@w3.org
Message-ID: <8eeb65c9-a54c-00a4-7bab-e2c6a0602fe4@novalistic.com>
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.

> An object A is called a sibling of an object B, if and only if B and 
> A share the same non-null parent.

I personally disagree with the change from L3 as it only serves to
confuse, but in any case, if L4 does mean to update the child-indexed
pseudos to match elements without parents, it should probably not use
the definitions from the DOM spec, but its own.
-- 
Daniel Tan
<http://NOVALISTIC.com>
Received on Wednesday, 6 September 2017 04:52:07 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:08 UTC