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

Add support for <relative‑selector‑list> in the :has(…) pseudo‑class #250

Closed
ExE-Boss opened this issue Sep 23, 2021 · 3 comments · Fixed by #279
Closed

Add support for <relative‑selector‑list> in the :has(…) pseudo‑class #250

ExE-Boss opened this issue Sep 23, 2021 · 3 comments · Fixed by #279
Assignees
Labels
feature-request Request for new features or functionality

Comments

@ExE-Boss
Copy link

ExE-Boss commented Sep 23, 2021

The :has(…) pseudo‑class, which is being prototyped in Blink, is specified as taking a <relative‑selector‑list>.

See also


More broadly, the function syntax for <pseudo‑class‑selector> is specified as taking <any‑value>, meaning that the current parser is too restrictive, and also too lax, as :is(1 - 2) should result in a warning, since 1 - 2 is not a valid selector, but because :is(…) takes a <forgiving‑selector‑list>, it’s equivalent to :is() at runtime, which is a valid selector that matches nothing.

The correct implementation would be to parse pseudo‑class arguments as <any‑value>, rather than as <complex‑selector‑list> | <calc‑sum> ]? as it currently does, and then perform stricter validation of the arguments based on the pseudo‑class/pseudo‑element itself.

@aeschli aeschli added the feature-request Request for new features or functionality label Oct 7, 2021
@aeschli
Copy link
Contributor

aeschli commented Oct 7, 2021

Thanks for the pointers. Do you have some real-world code snippets that I can use to test this?

@aeschli aeschli added this to the Backlog milestone Oct 7, 2021
@aeschli aeschli self-assigned this Oct 7, 2021
@romainmenke
Copy link
Contributor

romainmenke commented Feb 11, 2022

examples for :has with relative selectors : https://github.com/web-platform-tests/wpt/blob/master/css/selectors/invalidation/has-in-adjacent-position.html

div:has(.test) + #subject {
	background-color: red;
}

div:has(> .test) + #subject {
	background-color: green;
}

div:has(~ .test) + #subject {
	background-color: yellow;
}

div:has(+ .test) + #subject {
	background-color: blue;
}

div:has(~ div .test) + #subject {
	background-color: purple;
}

div:has(+ div .test) + # subject {
	background-color: pink;
}

@woody-li
Copy link

woody-li commented Jul 1, 2022

Safari 15.4 has supported the syntax, and Chrome 105 will support it in the near future.
Is it possibile to improve implementation priority.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants