Re: element existence selector

On 1 March 2015 at 04:36, Peter Krauss <ppkrauss@gmail.com> wrote:

> Hello,
> First a general and summarized reply:
>
> Only now I understand better what Tab Atkins said, sorry (!),
> about "*fast profile*"... It is in fact a standard for CSS,
>
>    http://www.w3.org/TR/selectors4/#fast-profile   (2013)
>    http://dev.w3.org/csswg/selectors-4/#profiles   (2015)
>
> so, we can put the discussion in this more objective terms:
>
> 1* the pseudo-selector* ":has()"*  not is a good candidate to
> *fast-profile*...  (All agree with the W3C csswg 2015's draft??)
>
> 2* the suggestion of an *":hasID()" can be a good alternative to
> the fast-profile*??
>

> NOTE:  *fast-profile* is a standard, so, we MUST agree that the standard
> defines a line separating fast from slow,
> it is not a personal taste matter... We can imagine a standard threshold
> in a standard benchmark-kit .
>
> - - - - -
> My position about item 1:
>   I agree  that is not fast.
>   Selector ":has()" is good for PrinceXML, but is not good for
> web-browsing in a tablet.
>
> My position about item 2:
>    I understand that "e1:hasID(#id1) #id2" is faster than "e1:has(any1)
> any2"
>    I understand that the only-ID  reduce the risk of complexity in a
> worst-case-set of selectors,
>    and CSS-parsing implementations based in  *getElementById()*  is
> faster than any others.
>    So, an ":hasID()" pseudo-selector can be use without performance
> reduction in a tablet.
>
>
> - - - -
>    As Henrik suggested when replying Tab, perhaps we need to "elaborate on
> why it is slow"
>    with worst-case examples and some benchmarking (ex. by jQuery).
>    Some explanation about "why is slow" is here,
>         http://stackoverflow.com/q/1817792/287948
>     "(...) The document can be traversed once, matching elements as you
> go,
>         with no need to ever go backward to adjust a match
>     "
>
> - - - -
> Thanks Daniel for correct syntax, yes,
>     html:has(#id1:hover) #id2
>

So then please use :has(#id) in your examples. There's no need to invent a
new pseudo-class function for that. If :has() with a simple id selector is
fast enough, it can be added to the fast profile, while :has() with other
selectors stays within the slow profile.

Sebastian

Received on Sunday, 1 March 2015 08:17:11 UTC