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

Re: [selectors4] :not and :matches specificity (was :not(a, b) vs. :not(a):not(b)

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 18 Apr 2013 00:13:11 -0700
Message-ID: <CAAWBYDBO9tw_MNENvgX64oNg9TQV5XTjw5opH2ZSpdQ7Vyxk8Q@mail.gmail.com>
To: Simon Sapin <simon.sapin@exyr.org>
Cc: www-style list <www-style@w3.org>
On Wed, Apr 17, 2013 at 11:50 PM, Simon Sapin <simon.sapin@exyr.org> wrote:
> Actually, can we combine the two? What’s the specificity of this one?
>
>     :not(#foo > :matches(h1, #bar))

It's the most specific branch, which means you find the most specific
:matches() branch and use that.  So the specificity is (2,0,0).

> In other words:
>
> In Selectors 3, Selectors are "functions" that map elements to booleans
> (matching or not), while the specificity is an intrinsic property of a
> selector, independent of the element being matched. Here it makes perfect
> sense for :not() to take the max specificity of its "arguments".
>
> The new behavior for :matches() changes that: I like to think of Selectors
> now as "functions" that map elements to either "null" (not matching) or a
> specificity, which depends on which branch was taken in :matches() pseudos.
> But now I don’t see how :not() taking the max specificity can make sense.

Unroll the :matches() and just write the selectors out manually.  Your
example becomes:

:not(#foo > h1, #foo > #bar)

The answer is now obvious.

~TJ
Received on Thursday, 18 April 2013 07:13:58 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 18 April 2013 07:13:58 UTC