Skip to content

fix: restore declarations for incompatible selectors after rule merge#1275

Open
PranavAchar01 wants to merge 1 commit into
parcel-bundler:masterfrom
PranavAchar01:fix/1260-incompatible-selector-merge-drops-declarations
Open

fix: restore declarations for incompatible selectors after rule merge#1275
PranavAchar01 wants to merge 1 commit into
parcel-bundler:masterfrom
PranavAchar01:fix/1260-incompatible-selector-merge-drops-declarations

Conversation

@PranavAchar01

Copy link
Copy Markdown

Summary

Fixes #1260.

When a style rule contains a mix of target-compatible and target-incompatible selectors, merge_style_rules merges the compatible portion into the preceding rule by draining style.declarations. This left the clones created for each incompatible selector with empty declarations; they were then silently discarded by the rule.is_empty() guard.

Reproduction:

/* Input — targets: Chrome 104 (:has() incompatible) */
.a:last-child { border-bottom: none; }
.a:last-child, .a:has(+ .b) { display: flex; }

Before fix:

.a:last-child { border-bottom: none; display: flex; }
/* .a:has(+ .b) { display: flex } was silently dropped */

After fix:

.a:last-child { border-bottom: none; display: flex; }
.a:has( + .b) { display: flex; }

Fix: snapshot style.declarations before the merge attempt and restore the snapshot into each incompatible-selector clone.

Test plan

  • cargo test passes (119/119 lib tests)
  • Added regression test using prefix_test with Chrome 104 targets that would have failed before this fix

🤖 Generated with Claude Code

…s them

When a style rule has both compatible and incompatible selectors for the
current targets, merge_style_rules drains the rule's declarations into the
preceding compatible rule. This left the incompatible-selector clones
with empty declarations, causing them to be silently dropped by is_empty().

Fix: snapshot the declarations before the merge attempt and restore them
into each incompatible-selector clone.

Fixes parcel-bundler#1260.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Incompatible selectors can be dropped after rule merging when targets require selector splitting

1 participant