#999: CSS Scoping; :has-slotted

Visit on Github.

Opened Sep 30, 2024

こんにちは TAG-さん!

I'm requesting a TAG review of :has-slotted.

The :has-slotted pseudo-class matches slot elements which have a non-empty list of slotted nodes. When :has-slotted matches a slot with fallback content, we can conclude that the fallback content is not being displayed.

Further details:

  • I have reviewed the TAG's Web Platform Design Principles
  • Relevant time constraints or deadlines:
  • The group where the work on this specification is currently being done:
  • The group where standardization of this work is intended to be done (if different from the current group):
  • Major unresolved issues with or opposition to this specification:
  • This work is being funded by:

You should also know that...

Discussions

2024-10-14

Minutes

Lea: Think this is ready. It's a pseudo-class that applies to <slot> elements when they have assigned nodes. We ought to make :slotted a combinator so you can use :has() for similar things, but we still need something that catches text nodes. Didn't call it :fallback-displayed because there's no guarantee that it has a fallback.

Peter: Seems like an no-brainer. My only "hmm" is a vague memory of doing this without the pseudo-element.

Lea: You posted the original proposal: https://github.com/w3c/csswg-drafts/issues/6867.

satisfied with:

<blockquote> We discussed this in a breakout today and we don't see any architectural concerns with this, so we're happy for this to move forwards. </blockquote>

Lea: Side-note: I don't like when the CSSWG uses pseudo-elements to address real DOM elements. It introduces a host of ergonomics problems that would not otherwise exist.

Peter: I'd like ::part() to be replaced by a way for the shadow tree to define its own pseudo-elements.

Lea: I'd like ::part() and ::slotted() to be replaced by ways to target real elements, e.g. special combinators to expose other elements. But that's a very big conversation that we cannot have in 5 minutes.