Re: [csswg-drafts] [selectors][css-scoping] Should `:host:has()` match? (#10693)

@emilio 

I'm not sure I understand the confusion. You have two entirely separate subtrees, both rooted in the same element; the two syntaxes match against one or the other. It seems unremarkable to me that they would do different things, because that's what happens *for every other possible selector as well*: normal selectors match against the shadow tree (which is where the stylesheet in question lives, so that's exactly what you'd expect), and `:host(...)` arguments match against the light tree.

@sorvell 
> Do you think it makes sense to support :host:empty as well?

Hm, yeah, that's workable under the same argument (it's only matching based on the non-host contents of the shadow, which are under the stylesheet author's control). It's only different from `:host:has(*)` in the case that the shadow contains text nodes but no elements, tho. 

Not sure it's particularly *useful* - it seems a lot more likely that that component knows whether it's put anything inside the shadow tree, and in particular, a `<style>` in the shadow would prevent it from matching, but there are ways to attach stylesheets without inserting nodes, so I guess it's reasonable...

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


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

Received on Thursday, 8 August 2024 23:04:31 UTC