-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[selectors] Wrapping with :is()
to get forgiveness changes semantics
#8430
Comments
You can use document.querySelectorAll('#test-elem:has(:is(:new-pseudo-with-limited-support),div span)') |
@Loirooriol yes but then you need to precisely identify which parts you consider problematic; this can be hard e.g. if what you pass to
suggests wrapping the whole selector part you're interested it, at least that's how I read it. |
You can also split document.querySelectorAll('#test-elem:is(:has(:new-pseudo-with-limited-support), :has(div span))'); But yeah, may be good to warn about this. Also in nesting when omitting |
Yeah, And since (Lifting it outside doesn't act quite the same - it'll prevent an invalid selector in :has() from invalidating the whole selector, but it won't let you drop just the invalid selector from the :has() argument and continue with the rest. But generally that should be fine.) |
The discussion in #7676 ended with a conclusion to make
:has()
unforgiving since you can always wrap its contents with:is()
or:where()
:This has been since incorporated into the spec at https://w3c.github.io/csswg-drafts/selectors/#typedef-forgiving-selector-list:
However, this doesn't look so simple to me, since
:is
/:where
take global selectors. For example, someone wanting to run:in a forgiving manner so that it works in browsers without support for
:new-pseudo-with-limited-support
may be surprised that the following:will no longer require both the
span
and its ancestordiv
to be descendants of#test-elem
.Do I not understand something about this recommendation or is it not precise enough?
The text was updated successfully, but these errors were encountered: