Skip to content

Keep the space before "of" in :nth-child() selectors - #456

Open
samipuro wants to merge 1 commit into
matthiasmullie:masterfrom
samipuro:fix/nth-child-of-selector
Open

samipuro wants to merge 1 commit into
matthiasmullie:masterfrom
samipuro:fix/nth-child-of-selector

Conversation

@samipuro

@samipuro samipuro commented Nov 5, 2026

Copy link
Copy Markdown

Fixes #426, fixes #441.

The An+B whitespace regex could capture an of <selector> argument, so li:nth-child(1 of :not(.x)) was minified to the invalid li:nth-child(1of :not(.x)).

The An+B parts can now no longer contain whitespace or parentheses. A second pass compacts An+B before of and keeps the space, e.g. :nth-child( -n + 3 of .item ) becomes :nth-child(-n+3 of .item).

Tests added to CSSTest. The first case fails before this change.

This branch has not been deployed

No deployments
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.

CSS Minification Removes Space in :nth-child(of <selector>), Causing Invalid CSS Nth-child with spaces inside gets broken

1 participant