-
Notifications
You must be signed in to change notification settings - Fork 757
Description
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. is used in
:is()and:where()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 so simple to me, since :is/:where take global selectors. For example, someone wanting to run:
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:
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?