[csswg-drafts] [selectors] Wrapping with `:is()` to get forgiveness changes semantics (#8430)

mgol has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors] Wrapping with `:is()` to get forgiveness changes semantics ==
The discussion in #7676 ended with a conclusion to make `:has()` unforgiving since you can always wrap its contents with `:is()` or `:where()`:

> fantasai: i support restricting to :is and :where, it's really simple, and because we do it this way you can control whether something is forgiving or not by wrapping in :is or :where

This has been since incorporated into the spec at https://w3c.github.io/csswg-drafts/selectors/#typedef-forgiving-selector-list:
> Note: Style rules still use the normal, unforgiving selector list behavior. [<forgiving-selector-list>](https://w3c.github.io/csswg-drafts/selectors/#typedef-forgiving-selector-list) is used in [`:is()`](https://w3c.github.io/csswg-drafts/selectors/#matches-pseudo) and [`:where()`](https://w3c.github.io/csswg-drafts/selectors/#where-pseudo) only. Although it does have some minor implications on specificity, wrapping a style rule’s selector in `:is()` effectively "upgrades" it to become forgiving, so long as it doesn’t contain any pseudo-elements (which aren’t valid in `:is()` or `:where()`).

However, this doesn't look as simple to me, since `:is`/`:where` take global selectors. For example, someone wanting to run:
```js
document.querySelectorAll('#test-elem:has(:new-pseudo-with-limited-support,div span)')
```
in a forgiving manner so that it works in browsers without support for `:new-pseudo-with-limited-support` may be surprised that the following:
```js
document.querySelectorAll('#test-elem:has(:is(:new-pseudo-with-limited-support,div span))')
```
will no longer require both the `span` and its ancestor `div` to be descendants of `#test-elem`.

Do I not understand something about this recommendation or is it not precise enough?


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8430 using your GitHub account


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

Received on Wednesday, 8 February 2023 15:51:57 UTC