Re: element existence selector

On Fri, Feb 27, 2015 at 4:04 PM, Daniel Tan <lists@novalistic.com> wrote:

> 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
> NOVALISTIC
> <http://NOVALISTIC.com>
>
>
Actually, there's not really a functional difference between a class and an
ID other than some minor internal details and the fact that getElementById
will automatically get you the first one in document order, so an ID really
wouldn't make much difference here on either the author or performance end.

-- 
Brian Kardell :: @briankardell :: hitchjs.com

Received on Friday, 27 February 2015 21:17:09 UTC