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

Re: element existence selector

From: Daniel Tan <lists@novalistic.com>
Date: Sat, 28 Feb 2015 05:04:31 +0800
Message-ID: <54F0DBDF.1030604@novalistic.com>
To: Peter Krauss <ppkrauss@gmail.com>
CC: www-style@w3.org
On 2/28/2015 1:30 AM, Peter Krauss wrote:
> Thanks Tab, now you find exacly what I was looking for (!)...
> Well, let's confirm it, with another words,
>   1* you are  referring to the  "4.4. The Relational Pseudo-class
> /:has()/ <http://dev.w3.org/csswg/selectors-4/#relational>";
>   2* what I need is to use /:has()/ as a root's condition, like
> /html:has(#id1)/;
>   3* the samantic of "/a:has(b) c/" is "if /b/ then selects /c/";
>   4* the semantic of "/html:has(#id1):hover #id2/" is "when
> on-mouse-over /#id1/, selects /#id2/";

Syntactically, the correct way of writing such a selector would be

html:has(#id1:hover) #id2
/* or :root:has(... */

> is it? assuming we agree until here, about this 4 assertions...
> And perhaps I understand  when you say "(...) too slow, and makes
> invalidating styles too difficult",
> but now imagine a more specific selector, a /:has()/ that can be used
> only with IDs,
> */:hasID()/ *
> so, why  "/html:hasID(#id1):hover #id2/"  will be slow? What the
> validation problem?
> Perhaps this ID constraints "put in rails" my suggestion:
> you see some parsing or validation problem with this hypothetical
> /:hasID()/?

Based on the explanation Boris has now given, I don't see how this will 
be any better than :has() except that it's restricted to an ID, which by 
itself has very little performance impact if at all.

What I can tell, as an author, is that this basically forces you to use 
IDs, so you will only be able to use it with unique elements in a 
conforming document. If you only have one (or two) elements that you'll 
be using this with, I guess it's fine, but if you have several related 
elements that you would normally otherwise select with a class, things 
will get very unwieldy from there.

Daniel Tan
Received on Friday, 27 February 2015 21:05:02 UTC

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