Skip to content

Allowing CSS combinators postfixed to the ::slotted() or :host selectors #889

@trusktr

Description

@trusktr

Borrowing some ideas from #883, I think it would be great to allow combinators after ::slotted(whatever), for example ::slotted(.foo) .bar > .lorem + ip-sum. Similarly, the previous selector would be effectively the same as :host > .foo .bar > .lorem + ip-sum for styling purposes, but :host also does not allow combinators to be appended to it.

Here's a live example showing that it currently doesn't work:

https://stackoverflow.com/questions/62842418

On the same token, being able to use these selectors in querySelector and querySelectorAll would be very convenient.

Here's a live example that shows that querySelector('::slotted(.foo)') doesn't work despite being a valid selector, and also showing that postfixed combinators throw an error:

https://codepen.io/trusktr/pen/d4a45f1efc9eccc0fdb20164566bada4?editors=1010

Having these features as expansions on the current spec would allow what the OP in #883 asks for: it would make it very easy to style the input tree that a custom element end user provides.

There are currently complicated ways to achieve this (see comments below).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions