W3C home > Mailing lists > Public > www-style@w3.org > October 2011

Re: Selectors 4 and Variables

From: François REMY <fremycompany_pub@yahoo.fr>
Date: Sat, 1 Oct 2011 10:06:55 +0200
Message-ID: <AB094FFB64884D819270A3524FA85066@FREMYD2>
To: "fantasai" <fantasai.lists@inkedblade.net>, <www-style@w3.org>
We can use the :has pseudo class and restricts his usage to achieve the same 
thing. Those allowed usages can then be extended over time, in function of 
what implementers are ready to do.

It seems clear to me that the goal of the "$" notation was to force the 
":has" to be at the last position of the selector. This allows to restrict 
the needed changes in the rule-matching algorithm to : "Allow a selector 
matching an element to have effect on his ancestrors". This mean the only 
restriction added to the system is that we should start to match CSS rules 
to the deepest point of the DOM Tree and go backward, which most UA probably 
do by now. If we allow :has everywhere, this assumption fails to be proven 
and we may need a more complex tooling to find matched elements for those 
rules, probably iterating two or more times the rule-matching algorithm each 
time a new "parent match" is found.

It may seems reasonable to restrict the :has pseudo-class to the last 
position of the selector. It achieves the same effect and it's easy to add 
more possibilities in the future without changing the syntax.

(Or maybe am I missing the point?)


-----Message d'origine----- 
From: fantasai
Sent: Saturday, October 01, 2011 5:15 AM
To: www-style@w3.org
Subject: Re: Selectors 4 and Variables

On 09/30/2011 05:03 PM, Tab Atkins Jr. wrote:
>
> I thought it was generally agreed long ago that the best approach was
> to use :has() rather than a marker in the selector.  It's more general
> and allows more types of things to be expressed.

It wasn't *generally* agreed. It was only agreed by some people.

> Basically, the subject indicator is exactly equivalent to a :has()
> pseudo limited to the end of the selector:
>
> foo $bar baz {...} == foo bar:has(baz) {...}
>
> However, :has() can be placed anywhere in the selector, and so allows
> more powerful selections:
>
> label:has(:checked) + section>  p {...}

The limitation to a single branch here is intentional, due to
implementation concerns.

If I were going to do branching, I'd expand :matches() to take full
selectors rather than only compounds.

label:matches(!#$%? :checked) + section > p { ... }

This has the advantage that selectors work the same whether they
are within or without the pseudo-class argument. There's neither
implicit nor dangling combinators, as you have with :has().

~fantasai 
Received on Saturday, 1 October 2011 08:07:18 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:45 GMT