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

@sorvell You seem to be confusing yourself about what it means for `:host(...)` to take a selector argument, versus having selectors following `:host`.  (And possibly have let emilio confuse you into thinking this issue is about `:host(:has(...))`, which it is not.)

* `:host(sel)` matches the selector argument against the host element *in the context of the outer (light) tree*. If `sel` would match the host element in that context, then `:host(sel)` matches the host element within the shadow.
* `sel:host` attempts to match the `sel` selector against the host element *in the context of the inner (shadow) tree*. Within the shadow, the host element is featureless, and only matches the exact selectors that are explicitly specified as allowed to match.

`:host(::after)` does not work because the host element does not match the selector `::after` - it's not an ::after pseudo-element! This happens to be true in *either* context, but is certainly true in the light context. `:host::after` works because `:host` is allowed to match the host element, and then `::after` isn't trying to match the host element, it's just a pseudo-combinator shifting you into matching the host's pseudo-elements; it's identical to `:host > div` in action.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10693#issuecomment-2276579000 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 20:14:25 UTC