W3C home > Mailing lists > Public > www-style@w3.org > July 2015

Re: [selectors4] Why is the :only-child pseudo-class not a special case in terms of specificity?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 23 Jul 2015 13:50:44 -0700
Message-ID: <CAAWBYDBDQyVuoNyru421LPWvt3sgojDJmsGVH-oiAGgj36ctyA@mail.gmail.com>
To: James Donnelly <jdonnelly30@gmail.com>
Cc: www-style list <www-style@w3.org>
On Tue, Jul 14, 2015 at 10:23 PM, James Donnelly <jdonnelly30@gmail.com> wrote:
> In both the Selectors recommendation and the Selectors4 working draft, the
> :only-child pseudo-class documentation states:
>> “Same as ‘:first-child:last-child’ or ‘:nth-child(1):nth-last-child(1)’,
>> but with a lower specificity.”
> As much as it would go against the basic specificity implementation,
> wouldn’t it be logical for the :only-child selector to have the same
> specificity as those combined selectors?

Why would that be useful?  It's defined in terms of :first-child and
:last-child, for simplicity, but it doesn't actually desugar to them.
The only time we violate the standard specificity rules is when the
pseudo-class is just a "context" for other selectors, like :matches().
Otherwise it would be confusing.

Received on Thursday, 23 July 2015 20:51:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:18 UTC