Skip to content

Commit 15642fb

Browse files
committed
Compare adjacent rules ignoring whitespace
1 parent 8845d11 commit 15642fb

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/jit/lib/collapseAdjacentRules.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ export default function collapseAdjacentRules() {
2222

2323
if (node.type === 'atrule' && node.name === 'font-face') {
2424
currentRule = node
25-
} else if (properties.every((property) => node[property] === currentRule[property])) {
25+
} else if (
26+
properties.every(
27+
(property) =>
28+
(node[property] ?? '').replace(/\s+/g, ' ') ===
29+
(currentRule[property] ?? '').replace(/\s+/g, ' ')
30+
)
31+
) {
2632
currentRule.append(node.nodes)
2733
node.remove()
2834
} else {

tests/jit/collapse-adjacent-rules.test.css

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
.font-bold {
3737
font-weight: 700;
3838
}
39+
.foo,
40+
.bar {
41+
color: black;
42+
font-weight: 700;
43+
}
3944
@media (min-width: 640px) {
4045
.sm\:text-center {
4146
text-align: center;

tests/jit/collapse-adjacent-rules.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ test('collapse adjacent rules', () => {
4747
url("/fonts/ProximaNova.woff") format("woff");
4848
}
4949
}
50+
.foo, .bar {
51+
color: black;
52+
}
53+
.foo,
54+
.bar {
55+
font-weight: 700;
56+
}
5057
`
5158

5259
return run(css, config).then((result) => {

0 commit comments

Comments
 (0)