As an update, I was chatting with Tab about this since there were conflicting statements about whether this was allowed per the spec, but based on the conclusion, this change would require a spec change.
The
CSS Selectors spec notes that "Since
:has() takes a
<relative-selector-list>, its arguments are inherently
complex selectors (because they start, perhaps implicitly, with a combinator). This means :has() cannot be used in contexts that don’t allow complex selectors; its arguments will be guaranteed to be invalid." And :host() is defined to take a <compound-selector>.
This conflicts with the tests added in
https://github.com/web-platform-tests/wpt/pull/47441, which indicate that :host(:has()) is supported.
I'll plan to open a new issue on the CSSWG to discuss further, and I can look into making the relevant tests tentative in the meantime.
(:host:has(), on the other hand, was resolved to be accepted per
https://github.com/w3c/csswg-drafts/issues/10693, so I have since marked those tests as non-tentative. This selector combination is already working as expected in Chromium).
Thanks,
Alison