Skip to content
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] Disallow standalone pseudo-elements in :nth-*-child() #8212

Closed
cdoublev opened this issue Dec 9, 2022 · 1 comment
Closed

[selectors] Disallow standalone pseudo-elements in :nth-*-child() #8212

cdoublev opened this issue Dec 9, 2022 · 1 comment

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Dec 9, 2022

::before:nth-child(1) is currently invalid. This is defined in a non-normative note for pseudo-classing in Selectors 4:

Note that, unless otherwise specified in a future specification, pseudo-classes other than the user action pseudo-classes are not valid when compounded to a pseudo-element; so, for example, ::before:first-child is an invalid selector.

There is a resolution to allow more pseudo-classes following a pseudo-element, but :nth-*-child() are not included.

I think pseudo-elements that are not associated to an originating pseudo-element should be invalid before/in :nth-*-child(), since :nth-child(1 of ::before) is equivalent to ::before:nth-child(1).

EDIT: actually no, I think :nth-child(1 of ::before) is equivalent to *:nth-child(1 of *::before), which can match nothing.

:nth-*-child() has been deferred to Selectors 5 in #3760 with the following resolution: defer complex selectors for all of these selectors and have a note in the current level mentioning this is an enhancement we'll get to in the next level. I do not see any mention of this in Selectors 4, maybe because it is already implemented in some browsers? I am not sure there are good use cases for using a pseudo-element as the subject or an argument of :nth-*-child() at the moment though.

I am not sure the concept of a pseudo-element defined with an internal structure will remain in Selectors 5, but I think a pseudo-element that can appear in such pseudo-element would also be valid in :nth-*-child().

@tabatkins tabatkins added the selectors-4 Current Work label Dec 9, 2022
@tabatkins
Copy link
Member

Fixed in 80e9be7, where we finally defined how pseudo-elements work in the compound/complex hierarchy. (They're a new "pseudo-compound", separate from compound, and only exist inside of complex selectors. Grammar has been updated to reflect this as well, in ae832ae)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants