Skip to content

Commit

Permalink
fix(postcss-merge-longhand): skip processing if diff not exactly 1 (#…
Browse files Browse the repository at this point in the history
…1222)

Fix #1217

Before we skipped if the diff was larger than 1, this excluded the case where the diff is 0.
Actually if the declarations are identical this part of the code should probably never execute in
the first place, but the issue only triggers with very specific CSS combinations so I could not
find a different fix.
  • Loading branch information
ludofischer committed Nov 5, 2021
1 parent 901edb5 commit 83009a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/postcss-merge-longhand/src/__tests__/borders.js
Expand Up @@ -1210,6 +1210,23 @@ test(
)
);

test(
'do not crash',
processCSS(
`.next-step-arrow[dir='rtl'] .next-step-item:before {
border: 16px solid transparent;
border-right: 16px solid transparent;
border: var(--step-arrow-item-border-width, 16px) solid transparent;
border-right-color: transparent;
}`,
`.next-step-arrow[dir='rtl'] .next-step-item:before {
border: 16px solid transparent;
border-right: 16px solid transparent;
border: var(--step-arrow-item-border-width, 16px) solid transparent;
}`
)
);

test(
'should overwrite some border-width props and save fallbacks and preserve case #648 2',
processCSS(
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-merge-longhand/src/lib/decl/borders.js
Expand Up @@ -87,7 +87,7 @@ function mergeRedundant({ values, nextValues, decl, nextDecl, index }) {

const diff = diffingProps(values, nextValues);

if (diff.length > 1) {
if (diff.length !== 1) {
return;
}

Expand Down

0 comments on commit 83009a0

Please sign in to comment.