Conversation
tommy230
force-pushed
the
fix/site-import-duplicate-class-order
branch
from
September 28, 2026 20:10
310db0d to
b8f5e8f
Compare
…ition A stylesheet that styled the same bare class twice had its second rule merged into the first, so the merged rule sat before any rule written between the two occurrences and lost cascade ties it wins in a browser. Each occurrence is now its own rule at its own source position. Both stay class-kind through parsing so cross-sheet conflict detection still sees the file's full definition; the registry demotes repeats at commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tommy230
force-pushed
the
fix/site-import-duplicate-class-order
branch
from
September 29, 2026 00:01
b8f5e8f to
f45cd30
Compare
tommy230
marked this pull request as ready for review
September 29, 2026 04:47
This branch has not been deployed
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
A stylesheet that styles the same bare class twice, with other rules in between, imports with the wrong winner. Frameworks do this on purpose: a grid sheet sets a column's gutter early, then zeroes it hundreds of rules later so a wrapper can carry it instead. After import the early value came back.
In a browser an element with
class="x y"getspadding-left: 0: the last equal-specificity rule wins. After import it gets7px.processBaseSelectorincssToStyleRules.tsmerged the second.xinto the first, so the merged rule sat before.yand.ywon the tie.The fix:
duplicate-classwarning still fires per repeat.kind: 'class'through parsing, so cross-sheet conflict detection still merges the file's full definition in order.normalizeBindableClassRulesdemotes them to ambient fragments after resolution, which is how repeats across files already work perdocs/features/site-import.md.@mediaor@supportsblock comes before its first base rule still imports as one class rule: the base declarations fill the rule the block opened.mainalso raised a spuriousduplicate-classwarning for that shape; it no longer does. An authored empty.x {}is not filled, so a later.xkeeps its own position.Trade-off: the class panel shows the first occurrence's declarations; a later repeat's override lives in an ambient fragment at its own position. That matches the existing behavior for the same class defined in two files. A
@mediablock that follows a repeat now attaches to that latest occurrence, so the published cascade is right but the class panel no longer lists that breakpoint override.Out of scope: a page that links the same stylesheet twice (the second link is still deduplicated), and
@mediaoverrides that attach to the base rule's position rather than the block's.Verification
bun run buildbun run lintbun test: 7057 pass, 0 failAcross the two touched test files (74 tests), 6 fail on
mainand pass with this change, all of them new or rewritten cases insrc/__tests__/siteImport/cssToStyleRules.test.ts.src/__tests__/siteImport/duplicateClassConflicts.test.tspasses on both and guards conflict detection against the new rule shape.Checklist
docs/features/site-import.md.)🤖 Generated with Claude Code