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

Re: [selectors] Are really arbitrary selectors allowed in :not()?

From: Benjamin Poulain <benjamin@webkit.org>
Date: Tue, 20 Jan 2015 12:38:25 -0800
Message-ID: <54BEBCC1.5020908@webkit.org>
To: Sebastian Zartner <sebastianzartner@gmail.com>
CC: www-style list <www-style@w3.org>
On 1/20/15 8:36 AM, Sebastian Zartner wrote:
> On 19 January 2015 at 19:57, Benjamin Poulain <benjamin@webkit.org> wrote:
>>
>> The selector list inside :not() applies to the element being matched.
>>
>> div:not(.someclass > span) never matches anything since no element would have the local names "div" and "span" simultaneously.
>
> Ok, that makes sense. Though IMO that is unclear from the
> specification. And it is also missing a proper example illustrating
> this behavior.
>
>> span:not(div > .someclass) matches any span that does not have a class "someclass" and is not under a div.
>
> So an equivalent to :not(div) > span:not(.someclass).
>
>> This selector already works in WebKit Nightly, you can try it there. It is really useful to get elements that are not the in certain subtrees, e.g. img:not(:any-link >> *)
>
> Is there a Windows build available somewhere?

Hum, nope, it is only OS X and Linux.

>> On 1/19/15, 2:03 AM, Sebastian Zartner wrote:
>>
>> Selectors Level 4 removes the restriction to simple selectors for the :not() pseudo-class and now allows it to take a selector list. The only restriction mentioned is that pseudo-elements are forbidden.
>> Does this mean it allows arbitrary selectors like matching descendants?
>>
>> Examples:
>> div:not(.someclass > span)
>> section:not(a:hover)
>>
>> I assume the selectors should be restricted to aspects of the element as in Level 3, i.e. :not() takes a list of *simple* selectors.
>> Otherwise it would cover the functionality of the :has() pseudo-class and fall into the category of complete selector profiles.
>>
>> Sebastian
>>
>>
Received on Tuesday, 20 January 2015 20:40:21 UTC

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