Re: [csswg-drafts] [selectors] `:nth-child(n of A)` should ignore default namespaces for A, same as `:is()` (#9804)

In the telcon discussion about #5684, dbaron summarized the justification of the :is()/etc behavior really well: we don't want to have the default namespace applied twice to the same element, via different selectors, such that it's easy to not override the default on one of them and get an inconsistent and confusing behavior.

So like in `svg|a.foo`, you only apply the rule once (nothing happens, since it already has an explicit namespace. In `svg|a:is(.foo)` you want to apply it only once as well, so you don't get an incompatible selector (effectively `svg|a:is(default|*.foo)`). But in a case like `svg|a:is(div .foo)`, it's fine for the default namespace to apply to the `div` selector, since that's a different element, same as if it were written `div svg|a.foo`.

So the general policy to draw here is, the default namespace rule should not apply to *any* pseudoclass's selector argument, for the component of that selector that applies to the same element as the pseudoclass itself.

Adopting this as a general policy would obviate this issue; it would automatically fall under the new rule. We could also remove the exception from :is()/etc, since they'd be auto-covered.

Notably, this does *not* cover `:has()`'s argument; since that selector is relative, none of its components apply to the element the `:has()` is on.

(And to be clear, this would only apply to parts that are *defined* as applying to the subject element. Writing `svg|a:has(:is(.foo *))` wouldn't do anything special to the `.foo` part, even if it ends up matching the `svg|a:has(...)` element, because that match-up is coincidental rather than by definition.)

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


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

Received on Wednesday, 17 January 2024 17:52:43 UTC