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-4] Add :has() to the list of logical combination pseudo-classes #10749

Closed
wants to merge 1 commit into from

Conversation

kbabbitt
Copy link
Collaborator

As discussed in #10693.

@kbabbitt kbabbitt requested review from fantasai and tabatkins August 16, 2024 23:56
@cdoublev
Copy link
Collaborator

I think pseudo-elements cannot be followed by :has().

This specification allows any pseudo-element to be followed by any combination of the logical combination pseudo-classes and the user action pseudo-classes.

There is probably a good reason for :has() to be in the "Logical Combinations" section but I see it as a tree-structural pseudo-class.

@kbabbitt
Copy link
Collaborator Author

I think pseudo-elements cannot be followed by :has().

This specification allows any pseudo-element to be followed by any combination of the logical combination pseudo-classes and the user action pseudo-classes.

Good point, this is an unintended consequence of the proposed edit I hadn't realized. ::first-line:has(...) seems like a reasonable thing to express but could lead to dependency cycles so I don't think we want to allow it. And I don't see how ::before, ::after, or ::first-letter could possibly match :has(), so there's no reason to allow those either.

There is probably a good reason for :has() to be in the "Logical Combinations" section but I see it as a tree-structural pseudo-class.

I can see both sides of this. On one hand, because :has() takes a <relative-selector-list> there's an implied OR between the selectors in that list. On the other hand, unlike :is(), :where() and :not(), :has() requires examining the tree beyond the subject of the selector. @tabatkins / @fantasai wdyt?

@tabatkins
Copy link
Member

It's not really a logical combination pseudo, which is why we didn't include it in that list in the first place. Logical combination pseudos don't do anything at all, theoretically, that you couldn't achieve by just writing out the selectors manually. (Well, :not() is a new ability, but it's such a clear mirror to what its argument can do that it's morally not new.) So allowing them, with the caveat that you can only use arguments that could already show up there by themselves, doesn't raise any questions.

:has() is totally new functionality, and can't be treated as cavalierly. Editing for #10693 needs to be a bit more fiddly, unfortunately.

@tabatkins tabatkins closed this Aug 22, 2024
@kbabbitt kbabbitt deleted the host-has branch August 22, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants