Skip to content

fix: preserve ancestor selectors for literal ampersands - #22

Merged
romainmenke merged 1 commit into
csstools:mainfrom
feritcemkahraman:fix/literal-ampersand-ancestors
Oct 10, 2026
Merged

romainmenke merged 1 commit into
csstools:mainfrom
feritcemkahraman:fix/literal-ampersand-ancestors

Conversation

@feritcemkahraman

Copy link
Copy Markdown
Contributor

Nested selectors containing only a quoted or escaped ampersand lose their ancestor selector. For example, .outer { .parent { [data-label="&"] { color: red } } } resolves to [data-label="&"] instead of .outer .parent [data-label="&"].

Use the existing quote/escape/block-aware splitter to decide whether the selector contains a nesting ampersand. Reuse the split parts when substituting an actual nesting selector. Literal-only ampersands now take the normal descendant path.

Validation:

  • Original full node --test: 39 passing tests.
  • Three new regressions (quoted attribute, escaped class name, attribute inside :is) fail before the source fix.
  • Full node --test after the fix: 42 passing tests, including existing actual-ampersand substitution cases.
  • git diff --check passes. No runtime dependencies added.

@romainmenke

Copy link
Copy Markdown
Member

thanks!

@romainmenke
romainmenke merged commit 7c97f32 into csstools:main Oct 10, 2026
4 checks passed
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.

2 participants