- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Fri, 27 Feb 2015 08:40:17 -0800
- To: Peter Krauss <ppkrauss@gmail.com>
- Cc: www-style list <www-style@w3.org>
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 16:41:11 UTC