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

Re: element existence selector

From: Peter Krauss <ppkrauss@gmail.com>
Date: Fri, 27 Feb 2015 14:30:04 -0300
Message-ID: <CAHEREtv=FO7b-whwkpvvESiTui5N0fBXLGYCoi=8oWNUUFBAGw@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style list <www-style@w3.org>
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*";

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()*?


Krauss



2015-02-27 13:40 GMT-03:00 Tab Atkins Jr. <jackalmage@gmail.com>:

> On Fri, Feb 27, 2015 at 6:37 AM, Peter Krauss <ppkrauss@gmail.com> wrote:
> > Since CSS2 we can express the "existence of attributes",
> >
> >    http://www.w3.org/TR/WD-CSS2/selector.html#h-5.7.1
> >
> > with the [att] selector,
> >
> >     element[att] {do}
> >
> > and it is easy implement this kind of conditional selector in CSS
> parsers...
> >
> > The suggestion (or question) here is about use the same ideia with
> elements,
> > a kind of existence operator,
> >
> >     e1 <existenceOperator> e2 {do}
> >
> > to say "if element e1 exists, selects the e2 element".
> >
> >
> > * if it is a new suggestion, can I discuss here this subject?
> >
> > * if there are some old discussion about it, sorry, can somebody reply
> with
> > a link?
> >
> > ------
> > PS: I think that this kind of <existenceOperator> can used in a big
> subset
> > of (imagined) applications of the problematic previous-sibling-selector,
> and
> > also used as a "trigger" in event selectors, like
> >       e1:hover <existenceOperator> e2 {do}
>
> Ah, now I get it.  You're splitting the selector into two completely
> separate parts; if the first part matches an element, you run the
> second part to actually select something.  More like "if(e1) then e2".
>
> So, in the full-powered :has() world (which will only exist for
> querySelector and similar APIs) this is just `:root:has(e1) e2`
> (assuming that no part of e2 is supposed to match the root; otherwise
> you have to merge the first compound selector of e2 into the :root
> one).
>
> Unfortunately, this won't get into the fast profile (what's supported
> in stylesheets) for the same reason that full-powered :has() won't;
> it's way too slow, and makes invalidating styles too difficult, since
> a change *literally anywhere in the document* can affect whether the
> selector matches the e2 element.
>
> The specific use-case you pointed to in your link might be possible,
> though.  We agreed to add some pseudo-classes to help select cells in
> the same column of a table; selecting cells in the same row is usually
> handled by the sibling combinators, but the presence of rowspan does
> mess things up a bit.
>
> ~TJ
>
Received on Friday, 27 February 2015 17:30:32 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:01 UTC