-
Notifications
You must be signed in to change notification settings - Fork 716
[selectors] :nth-child(n of A)
should ignore default namespaces for A, same as :is()
#9804
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
Comments
:nth-child(n of A)
should ignore default namespaces for A, same as :is()
:nth-child(n of A)
should ignore default namespaces for A, same as :is()
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 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 (And to be clear, this would only apply to parts that are defined as applying to the subject element. Writing |
I think this can get a bit tedious, like in |
No, that's exactly the opposite of what I said. ^_^ In |
The
:is()
,:not()
, and:where()
pseudos all have text that states that if the final compound selector in their arguments doesn't have a type selector, we ignore the general rule that requires them to match the default namespace (when one exists).(That is, given
@namespace "http://example.com";
, a selector like.foo
is implicitly only selecting elements from that default namespace; you have to explicitly write*|*.foo
to get back to the normal behavior of allowing any namespace to match. This doesn't apply to:is()
/etc arguments.)This special behavior exists to ensure that the combo pseudoclasses intuitively work correctly when used as syntax sugar; that is, given any selector
AB
, replacing it withA:is(B, C)
is guaranteed to match all the same elements, and possibly more. See #5684 for more details.This same argument should apply to the
n of A
arguments to:nth-child()
/etc: going fromAB
toA:nth-child(n of B)
should match the exact same elements. Currently (lacking the special rule that:is()
/etc have), this isn't necessarily true; changingsvg|a.foo
tosvg.a:nth-child(n of .foo)
makes it stop matching anything at all, if the default namespace is not SVG.The text was updated successfully, but these errors were encountered: