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

Yeah, `:is()` is a no-op (ignoring specificity) *if* you wrap an *entire* selector in it, or you wrap just a compound selector in it. If you have a combinator inside the `:is()` *and* outside it, it does indeed change the behavior.

And since `:has()`'s argument is a relative selector, it *always* has a (perhaps implicit) combinator at the start, which you can't include in the `:is()`, so wrapping the entire `:has()` argument will always run afoul of this issue. You have to instead push it down to just wrap compound selectors, or lift it entirely outside as `:is(:has(...))`.

(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.)

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8430#issuecomment-1439231221 using your GitHub account


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

Received on Tuesday, 21 February 2023 23:39:03 UTC