-
Notifications
You must be signed in to change notification settings - Fork 27
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
:nth-*
pseudo-classes interoperability
#225
Comments
Yes, the |
I've had developer requests for this API. Glad we are considering it. |
I'm a bit concerned about the performance characteristics of the |
My immediate reaction was that we should be able to have a map from selector to index in our NthIndexCache like we have a map for element type to index today. I think our invalidation code could invalidate based on invalidation sets for selectors inside |
Of course, even with the cache, doing the linear matching of N siblings can still get crazy expensive if the selector inside the :nth() involves descendants, indirect siblings and :has(). |
WebKit has a CSSJIT implementation for |
That doesn't save you from exponential time tho, it only makes matching each sibling faster, right? |
CSSJIT is mostly for selector matching, yes. |
There were 3 mentions of nth-* in State of CSS 2022, which was not enough to make the top list in #248. Here they are:
|
In the MDN short survey on CSS & HTML, "CSS |
Thank you for proposing We are pleased to let you know that this proposal was accepted as part of the CSS Pseudo-classes focus area. You can follow the progress of this Focus Area on the Interop 2023 dashboard. For an overview of our process, see the proposal selection summary. Thank you for contributing to Interop 2023! Posted on behalf of the Interop team. |
Description
:nth-child
/:nth-last-child
/:nth-of-type
/:nth-last-of-type
accordingly (Blink/Gecko do this properly, WebKit does not)of <selector-list>
syntax for:nth-child
/:nth-last-child
(WebKit supports this)Rationale
Interoperability issues for something that is very basic and commonly used by web developers.
Specification
https://w3c.github.io/csswg-drafts/selectors-4/#child-index
Tests
Tests for item 1:
css/selectors/child-indexed-no-parent.html
css/selectors/child-indexed-pseudo-class.html
css/selectors/selector-structural-pseudo-root.html
Tests for item 2:
css/selectors/nth-child-and-nth-last-child.html
css/selectors/nth-child-of-classname.html
css/selectors/nth-child-of-complex-selector.html
css/selectors/nth-child-of-compound-selector.html
css/selectors/nth-child-of-tagname.html
css/selectors/nth-child-specificity-1.html
css/selectors/nth-child-specificity-2.html
css/selectors/nth-child-specificity-3.html
css/selectors/nth-child-specificity-4.html
css/selectors/nth-last-child-of-classname.html
css/selectors/nth-last-child-of-complex-selector.html
css/selectors/nth-last-child-of-compound-selector.html
css/selectors/nth-last-child-of-style-sharing-1.html
css/selectors/nth-last-child-of-style-sharing-2.html
css/selectors/nth-last-child-of-tagname.html
css/selectors/nth-last-child-specificity-1.html
css/selectors/nth-last-child-specificity-2.html
css/selectors/nth-last-child-specificity-3.html
css/selectors/nth-last-child-specificity-4.html
Some WebKit layout tests I haven't got around to porting, that might be worth adding:
LayoutTests/fast/css/nth-last-child-of-style-update-optimization.html
LayoutTests/fast/selectors/nth-last-child-of-cannot-match-during-parsing-1.html
LayoutTests/fast/selectors/nth-last-child-of-cannot-match-during-parsing-2.html
LayoutTests/fast/selectors/nth-last-child-of-class-style-update.html
LayoutTests/fast/css/parsing-css-nth-child-of-1.html
LayoutTests/fast/css/parsing-css-nth-child-of-2.html
LayoutTests/fast/css/parsing-css-nth-child-of-3.html
LayoutTests/fast/css/parsing-css-nth-child-of-4.html
LayoutTests/fast/css/parsing-css-nth-child.html
LayoutTests/fast/css/parsing-css-nth-last-child-of-1.html
LayoutTests/fast/css/parsing-css-nth-last-child-of-2.html
LayoutTests/fast/css/parsing-css-nth-last-child-of-3.html
LayoutTests/fast/css/parsing-css-nth-last-child-of-4.html
The text was updated successfully, but these errors were encountered: