- From: Alison Maher via GitHub <sysbot+gh@w3.org>
- Date: Thu, 06 Mar 2025 21:44:08 +0000
- To: public-css-archive@w3.org
alisonmaher has just created a new issue for https://github.com/w3c/csswg-drafts: == [selectors][css-scoping] Should :host:(has()) match? == The group recently resolved to allow `:host:has()` per https://github.com/w3c/csswg-drafts/issues/10693#issuecomment-2289330553. 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 https://github.com/w3c/csswg-drafts/issues/10693#issue-2449386187 and tests added in https://github.com/web-platform-tests/wpt/pull/47441. Safari already supports the tests for `:host(:has())` added in https://github.com/web-platform-tests/wpt/pull/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](https://drafts.csswg.org/selectors-4/#relational) that "Since [:has()](https://drafts.csswg.org/selectors-4/#has-pseudo) takes a [<relative-selector-list>](https://drafts.csswg.org/selectors-4/#typedef-relative-selector-list), its arguments are inherently [complex selectors](https://drafts.csswg.org/selectors-4/#complex) (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>`](https://drafts.csswg.org/css-scoping/#selectordef-host). Given that some browsers already support `:host:(has())`, given we already support `:host:has()` variant, and given author use cases (as called out in https://github.com/w3c/csswg-drafts/issues/7953#issuecomment-1366910447) I am wondering if we should reconsider either: 1. If `:has()` should be a `<complex-selector>` (which was discussed in https://github.com/w3c/csswg-drafts/issues/10693) 2. Update what is allowed in `:host()` (which was previously discussed in https://github.com/w3c/csswg-drafts/issues/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 Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11859 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 6 March 2025 21:44:09 UTC