Re: [csswg-drafts] [selectors] Pseudo-class to indicate when a slot has content (#6867)

> RESOLVED: :has-slotted should match when the fallback content is not being displayed

This resolution does not fit with the general [consensus](https://github.com/w3c/csswg-drafts/issues/6867#issuecomment-2368965064) in this issue that `:has-slotted` should behave generally consistent with `::slotted()`, modulo text nodes.

The need here is to know if renderable content has been supplied to the slot. Unfortunately, this is not the same as if it will show fallback content. This is because a `<slot>` *does not* render but *does* prevent fallback content.

The ability to select if fallback content is showing, if specific elements have been slotted, or if slots themselves have been slotted should be handled as follow-on cases since they are (1) less needed and more complex, and (2) could be covered by a functional form and/or a combinator if/when that is possible.

**Proposal** 

`::slotted()` matches the flattened tree so `:has-slotted` should as well. `:has-slotted` should match when `assignedNodes({flatten: true}).length > 0`. This is the same as when slotted(*)` would match except in the case of the default slot which can assign text nodes.


-- 
GitHub Notification of comment by sorvell
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6867#issuecomment-2583625976 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 10 January 2025 19:03:00 UTC