Re: [shadow-styling] /shadow vs /shadow-all

On 02/10/2014 03:57 PM, Tab Atkins Jr. wrote:
> The /shadow-all combinator is exactly the older ^ combinator from
> previous updates.  I added the /shadow combinator (which only selects
> the top-level elements in the shadow tree) based on suggestions from
> Boris and Jonas that there should be an easy way to select into a
> shadow tree without implicitly invoking a descendant combinator, due
> to the performance implications of descendant combinators.
>
> My coworker Elliot pointed out privately, though, that moving only
> into the top-level elements makes the styling more brittle - if the
> component author rearranges their shadow DOM so that something isn't a
> child anymore, it'll break users.
>
> He'd prefer that the shortest name go to something that isn't as
> brittle.  He also pointed out that, with bottom-up selector matching,
> there's not actually any real cost difference between /shadow and
> /shadow-all, since you can always cheaply jump from an element in a
> shadow tree directly up to the shadow host in any reasonable
> implementation.  (For the same reasons that any element can cheaply
> jump up to the document in any reasonable implementation.)
>
> This seems compelling to me.  I'd like to swap things around to have
> /shadow be the old ^ combinator, where it selects all the elements in
> the shadow tree, and either rename the "only top-level elements" one
> to /shadow-child, or just kill it and rely on use of :top to handle
> this use-case.

I think this really points to a pseudo-element being the better
way to go. You can use descendant and child combinators as usual
and don't need to bother with this awkward :top stuff.

~fantasai

Received on Wednesday, 19 February 2014 17:05:38 UTC