fix: avoid wrapping pseudo-element selectors in :is() during nesting compilation#1156
Open
donlion wants to merge 1 commit intoparcel-bundler:masterfrom
Open
fix: avoid wrapping pseudo-element selectors in :is() during nesting compilation#1156donlion wants to merge 1 commit intoparcel-bundler:masterfrom
donlion wants to merge 1 commit intoparcel-bundler:masterfrom
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Before (incorrect):
After (correct):
Root Cause
The
is_simple()function returnsfalsefor selectors with pseudo-elements because they internally contain aCombinator::PseudoElementcomponent. 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_nestingto 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
:is()wrapping of pseudo-elements + nested media query produces invalid CSS #975 to handle the.parent &case (where&is not at the start)Test Plan
cargo test)