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

@keithamus 

> I'm going to [Agenda+](https://github.com/w3c/csswg-drafts/labels/Agenda%2B) as I'd like to capture a resolution that the current behaviour of not matching the flat tree is okay

Based on the 3rd row of the [table here](https://github.com/w3c/csswg-drafts/issues/6867#issuecomment-2395119379), it's my opinion that:

**The bare form of `:has-slotted` should match against the same tree (text node inclusive) as `::slotted(...)`.**  

Note, it's slightly confusing to call this the flattened tree because `assignedNodes({flatten: true})` contains fallback content but `::slotted` does not match it.

The basic use case for this: 
1. I have a button that needs different styling based on the presence of an icon. I will use `:has-slotted` to achieve this.
2. If I want to allow a user of my composite element to take advantage of this feature, I'd do: `<my-button><slot name="icon"></slot></my-button>`. 
3. We need to match the "flattened"/`::slotted` tree to support this.

There are 2 separate issues which I think should be considered orthogonal to `:has-slotted`:
1. matching out of scope distributed fallback content: there's currently no way to do this with `::slotted` either so this shouldn't be uniquely handled by `has-slotted`.
4. matching against whitespace only: there's also an issue with this using `:empty` so similarly we shouldn't uniquely handle it here.

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


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

Received on Monday, 4 November 2024 20:17:23 UTC