fix: keep extracted longhands from being reset by leftover shorthands - #499
Closed
dyk1454683243-sudo wants to merge 2 commits into
Closed
dyk1454683243-sudo wants to merge 2 commits into
dyk1454683243-sudo wants to merge 2 commits into
Conversation
When restructRuleset pulls equal declarations into a shared rule, a longhand such as background-size can end up before a leftover background shorthand and get reset in the browser. Refuse to extract a declaration when a remaining unique shorthand would sit after it (or when an extracted shorthand would sit after a remaining longhand) and reset its atoms. Unrelated equals still merge. Fixes css#478. Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
Author
|
Withdrawing this PR while I clean up a high-volume open-PR backlog. Sorry for the noise — happy to come back later with a focused change if useful. |
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.
Problem
After restructure, a longhand that appears after a shorthand in the source can be pulled into a shared rule that sits before leftover shorthands. The later shorthand resets the longhand in the browser.
Minimal repro from #478:
Previously became:
backgroundthen wipesbackground-size.The same class of bug shows up with
border/border-bottom(#417) and withall.Root cause
8-restructRulesetextracts equal declarations into a new shared rule. For the usual merge-up path that rule is inserted before both leftovers.compareDeclarationsonly compares declaration identity — it does not know thatbackgroundresetsbackground-size.Fix
lib/restructure/propertyFamily.js), in the same spirit as the unfinishedproperty-familybranch.compareDeclarationsSaferefuses to extract a declaration when a leftover unique would sit on the other side of it and reset its atoms:backgroundthenbackground-size) are unchanged. Different!importantflags make order irrelevant, so those longhands can still be extracted.allis treated as resetting every property exceptunicode-bidianddirection.Tests
fixtures/compress/restructure.merge/issue-478*.css— issue repro, shared unrelated props, subset after / before,!important,allfixtures/compress/restructure.merge/issue-417.css—border-bottom/bordertest/propertyFamily.js— overlap / reset helpersnpm test: 549 passing, 4 pendingnpm run lint: cleanFixes #478
Related: #196, #417