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

Re: [selectors] Validity of pseudo-elements per context

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 27 Aug 2015 12:38:48 +0200
Message-ID: <CAAWBYDCA_pCapAyZz6ZU6WTo8_D2HAEgK2pUKaUAGHVFHBMGoA@mail.gmail.com>
To: fantasai <fantasai.lists@inkedblade.net>
Cc: "www-style@w3.org" <www-style@w3.org>, Anne van Kesteren <annevk@annevk.nl>
On Thu, Aug 27, 2015 at 3:07 AM, fantasai <fantasai.lists@inkedblade.net> wrote:
> We don't define anywhere what pseudo-elements the DOM methods accepting
> a selector are allowed to use.
>
> For example, IIRC they can only return elements, so any selectors that
> use most pseudo-elements should be invalid. E.g. ::selection, ::before,
> ::first-letter, etc. should all be invalid.
>
> However, we might want that using ::shadow or ::content as a combinator
> is valid, so that
>   ::shadow
> is either invalid or returns nothing but
>   ::shadow div
> is valid and returns <div> descendants of any shadow trees.
>
> I think this should be done by DOM specifying what it accepts rather
> than Selectors defining what DOM should accept.

You're confusing some issues.

Wrt whether pseudo-elements should be returned by the matching
algorithm when some API invokes it, that's controlled by an argument
to the matching algorithm already.  You specify when you invoke it
which pseudo-elements you want to allow in your result set.

Wrt whether pseudo-elements are valid or invalid in a particular
invoking context is of course definable by whatever thing is invoking
Selectors.  We alter the set of "valid" things depending on context
for several selectors in the spec already.

> So
>
> 1. We need to decide whether .query("::shadow") is throws SyntaxError
>    or returns nothing.

We don't need to, no.  DOM needs to; in the absence of anything
redefining the valid set of selectors, we default to the UA's generic
notion of "everything I understand", so it's valid but matches
nothing.

> 2. We need edits saying that the various DOM methods support all selectors
>    in the Selectors 4 module plus the selectors in the CSS Scoping Module
>    (or not), and nothing that no other pseudo-elements (e.g. those in
>    Selectors 3) are valid. Probably this text should go in DOM, but could
>    go into Selectors 4 (+ CSS Scoping) if necessary.

No we don't; DOM just needs to invoke the Selectors algorithm and
everything is included implicitly.

~TJ
Received on Thursday, 27 August 2015 10:39:36 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 27 August 2015 10:39:37 UTC