[CSS4 Selectors] :matches() :not() comma-separated list (was Re: [CSSWG] ... F2F Kyoto])

On 11/06/2011 4:17 AM, Tab Atkins Jr. wrote:
> On Fri, Jun 10, 2011 at 11:03 AM, Daniel Glazman
> <daniel.glazman@disruptive-innovations.com>  wrote:
>> Le 10/06/11 18:39, fantasai a écrit :
>>
>>> Selectors Level 4
>>> -----------------
>>>
>>> fantasai presented the idea of a new level of Selectors. The current
>>> draft excludes pseudo-elements (which would be a separate module) and
>>> adds
>>> - :matches() and :not() that take a comma-separated list of selectors

>> OMG !!! I implemented the last one back in 1996 in my STTS processor...
>> Finally. Please not that if we have that (I implemented it in two
>> flavors: :subject and a ! descriptor), I'm not sure we need :matches().
>
> :matches() does something completely different than the subject
> selector.  They can't be compared in functionality.  :matches() just
> lets you collapse places where you have to repeat a selector several
> times because of small possible variations.
>
[snipped
> Here's the same thing using :matches():
>
> :matches(dir, menu, ol, ul) :matches(dir, menu, ol, ul) :matches(dl, menu, ul) {
>    list-style-type: square;
> }
>
> ~TJ


I like this selector. It can be chained arguments or descendant 
arguments (if that is correct to use).

:matches(foo):not(bar) { ... }

:matches(foo) :not(bar) { ... }

I presume negation is not used often by authors since :not(bar) matches 
all elements within a document (except 'bar' of course).

One thing I have noted since 2007 [1], and that is WebKit has a negation 
specificity bug. We would want :matches(div) and :not(div) to have the 
same specificity of 0-0-1.

Currently WebKit parses :not(div) with having a specificity of 0-1-0.

<!doctype html>

<style type="text/css">
body {color: white;}
body :not([foo]) {background: green;}
body :not(bar) {background: red;}
</style>

<p>This paragraph should have a green background.</div>


Questions. Are these allowed?

:matches([foo],[bar]) { ... }

:matches(foo,[bar]) { ... }

:matches([foo],bar) { ... }




[1] http://css-class.com/test/css/selectors/specificity-negation.htm


-- 
Alan Gresley
http://css-3d.org/
http://css-class.com/

Received on Saturday, 11 June 2011 07:46:43 UTC