Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue#1112 #1116

Merged
merged 3 commits into from May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/postcss-merge-rules/src/__tests__/index.js
Expand Up @@ -815,3 +815,11 @@ test(
'a,a:link,a:visited{color:#555}'
)
);

test(
'should not merge colors',
processCSS(
'h1{color:#001;color:#002;color:#003}h2{color:#001;color:#002}',
'h1{color:#001;color:#002;color:#003}h2{color:#001;color:#002}'
)
);
20 changes: 11 additions & 9 deletions packages/postcss-merge-rules/src/index.js
Expand Up @@ -206,23 +206,25 @@ function partialMerge(first, second) {

// Filter out intersections with later conflicts in First
intersection = intersection.filter((decl, intersectIndex) => {
const index = indexOfDeclaration(firstDecls, decl);
const indexOfDecl = indexOfDeclaration(firstDecls, decl);
const nextConflictInFirst = firstDecls
.slice(index + 1)
.find((d) => isConflictingProp(d.prop, decl.prop));
if (!nextConflictInFirst) {
.slice(indexOfDecl + 1)
.filter((d) => isConflictingProp(d.prop, decl.prop));
if (!nextConflictInFirst.length) {
return true;
}
const nextConflictInIntersection = intersection
.slice(intersectIndex + 1)
.find((d) => isConflictingProp(d.prop, decl.prop));
if (!nextConflictInIntersection) {
.filter((d) => isConflictingProp(d.prop, decl.prop));
if (!nextConflictInIntersection.length) {
return false;
}
if (declarationIsEqual(nextConflictInFirst, nextConflictInIntersection)) {
return true;
if (nextConflictInFirst.length !== nextConflictInIntersection.length) {
return false;
}
return false;
return nextConflictInFirst.every((d, index) =>
declarationIsEqual(d, nextConflictInIntersection[index])
);
});

// Filter out intersections with previous conflicts in Second
Expand Down