Skip to content

fix: avoid wrapping pseudo-element selectors in :is() during nesting compilation#1156

Open
donlion wants to merge 1 commit intoparcel-bundler:masterfrom
donlion:fix/nesting-pseudo-element-is-wrapper
Open

fix: avoid wrapping pseudo-element selectors in :is() during nesting compilation#1156
donlion wants to merge 1 commit intoparcel-bundler:masterfrom
donlion:fix/nesting-pseudo-element-is-wrapper

Conversation

@donlion
Copy link

@donlion donlion commented Feb 19, 2026

Summary

When compiling nested selectors like .parent & where the parent selector contains a pseudo-element (e.g., .element::after), the code was incorrectly wrapping the parent in :is(), producing invalid CSS.

Input:

.element::after {
  .parent & {
    color: red;
  }
}

Before (incorrect):

.parent :is(.element:after) {
  color: red;
}

After (correct):

.parent .element:after {
  color: red;
}

Root Cause

The is_simple() function returns false for selectors with pseudo-elements because they internally contain a Combinator::PseudoElement component. This caused the nesting serialization to fall back to using :is(), which cannot contain pseudo-elements per CSS specification.

Fix

Added a check in serialize_nesting to detect when the parent selector contains a pseudo-element. In that case, we serialize the selector directly instead of wrapping it in :is().

Related Issues

Test Plan

  • Added test case for the specific scenario
  • All existing tests pass (cargo test)

…compilation

When compiling nested selectors like `.parent &` where the parent selector
contains a pseudo-element (e.g., `.element::after`), the code was incorrectly
wrapping the parent in `:is()`, producing invalid CSS like `.parent :is(.element:after)`.

The :is() pseudo-class cannot contain pseudo-elements per CSS specification.
This fix adds a check to serialize pseudo-element selectors directly instead.
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.

Ligthning generate :is with pseudo element

1 participant