You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The group recently resolved to allow :host:has() per #10693 (comment). This allows an author to select the host element if it has a descendent in the shadow DOM matching a provided relative selector list.
:host(:has()) is similar to :host:has() except it would match against descendants in the light DOM. It was noted in that issue that :host(:has()) is already defined to work per the following comment #10693 (comment) and tests added in web-platform-tests/wpt#47441.
Safari already supports the tests for :host(:has()) added in web-platform-tests/wpt#47441, and Firefox supports some. Chromium does not yet support :host(:has()), but it does support :host:has().
There was some confusion on whether :host:(has()) is allowed, but per spec, it is not currently supported. 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>.
Given that some browsers already support :host:(has()), given we already support :host:has() variant, and given author use cases (as called out in #7953 (comment)) I am wondering if we should reconsider either:
The group recently resolved to allow
:host:has()per #10693 (comment). This allows an author to select the host element if it has a descendent in the shadow DOM matching a provided relative selector list.:host(:has())is similar to:host:has()except it would match against descendants in the light DOM. It was noted in that issue that:host(:has())is already defined to work per the following comment #10693 (comment) and tests added in web-platform-tests/wpt#47441.Safari already supports the tests for
:host(:has())added in web-platform-tests/wpt#47441, and Firefox supports some. Chromium does not yet support:host(:has()), but it does support:host:has().There was some confusion on whether
:host:(has())is allowed, but per spec, it is not currently supported. 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>.Given that some browsers already support
:host:(has()), given we already support:host:has()variant, and given author use cases (as called out in #7953 (comment)) I am wondering if we should reconsider either::has()should be a<complex-selector>(which was discussed in [selectors][css-scoping] Should:host:has()match? #10693):host()(which was previously discussed in [css-scoping-1] Clarify exactly what :host(<sel>) can use as argument #7953)I suspect the latter of the two is more likely the route to take but would be open to thoughts from the wider community.
CC @tabatkins @Westbrook @justinfagnani