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

> where are you seeing the :has-slotted selector being available? Feels like the optimal usability of it would benefit from it being available all the way up to :host:has-slotted([slot=name]).

It's on the `slot`, indicating that that particular `slot` element has slotted content in it. If you want to style the host based on whether any of its slots have slotted content, you can use `:has(slot:has-slotted)` to check. ^_^

> An interesting edge case to consider will be slots with default content as well. Does default content count as has-slotted?

I'd say no. It's not slotted content, and in particular, it's not useful to *detect* slotted content in this case if this is true. That is, if `:has-slotted` matches a slot with default contents, then what would one do with the selector? It becomes *guaranteed* to match, and at that point you can just put a class on the `slot` and use that instead. On the other hand, having it *not* match when the slot is using its default content lets you make a meaningful distinction that you can only know at runtime, which is useful.

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


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

Received on Monday, 6 February 2023 21:14:25 UTC