Skip to content

Commit 182128f

Browse files
test(css): cover the comparison's rewrites, fold the change into the pending changeset
1 parent c91754d commit 182128f

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎.changeset/104-css-minify-shorthand-folds.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"webpack": patch
33
---
44

5-
Fold CSS longhands, shorten `flex`, shapes, shadows and omittable values, drop overridden rules, and fix edge cases.
5+
Fold CSS longhands, shorten `flex`, shapes, shadows, selectors and omittable values, drop overridden rules, and fix edge cases.

‎lib/css/syntax-parser.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11791,8 +11791,9 @@ const _conditionItems = (text) => {
1179111791
i = close[i] + 1;
1179211792
} else {
1179311793
let end = i;
11794-
while (end < text.length && _isIdentCodePoint(text.charCodeAt(end)))
11795-
{end++;}
11794+
while (end < text.length && _isIdentCodePoint(text.charCodeAt(end))) {
11795+
end++;
11796+
}
1179611797
if (end === i) return null;
1179711798
items.push(text.slice(i, end));
1179811799
i = end;

‎test/unitCases/CssSyntax.unittest.js‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14927,6 +14927,10 @@ describe("CssSyntax minify — what a comparison with other minifiers found", ()
1492714927
// A keyword starting its slot as the one word filling it says nothing.
1492814928
["a{animation:.2s steps(2) normal forwards running x}", "a{animation:.2s steps(2)forwards x}"],
1492914929
["a{animation:x 1s ease}", "a{animation:x 1s}"],
14930+
[
14931+
"a{animation:.2s cubic-bezier(.38,0,.24,1) normal forwards running x}",
14932+
"a{animation:.2s cubic-bezier(.38,0,.24,1)forwards x}"
14933+
],
1493014934
// Two words filling a slot make the second the name.
1493114935
["a{animation:1s reverse normal}", "a{animation:1s reverse normal}"],
1493214936
["a{animation:1s normal normal}", "a{animation:1s normal normal}"],
@@ -14987,6 +14991,7 @@ describe("CssSyntax minify — what a comparison with other minifiers found", ()
1498714991
["@supports not (((a:b) or (c:d))){a{x:1}}", "@supports not ((a:b) or (c:d)){a{x:1}}"],
1498814992
["@supports (a:b) and ((c:d)){a{x:1}}", "@supports (a:b) and (c:d){a{x:1}}"],
1498914993
['@supports (content:"((x))"){a{x:1}}', '@supports (content:"((x))"){a{x:1}}'],
14994+
[String.raw`@supports ((--x:a\(b)){a{x:1}}`, String.raw`@supports (--x:a\(b){a{x:1}}`],
1499014995
[
1499114996
"@container scroll-state(stuck : top) and style(--x: 1){a{x:1}}",
1499214997
"@container scroll-state(stuck:top) and style(--x: 1){a{x:1}}"
@@ -15023,6 +15028,14 @@ describe("CssSyntax minify — what a comparison with other minifiers found", ()
1502315028
"@supports (-webkit-mask-image:none) or (mask-image:none) or (x:y){a{x:1}}",
1502415029
"@supports (mask-image:none) or (x:y){a{x:1}}"
1502515030
],
15031+
[
15032+
"@supports ((selector(a)) or (x:y)){a{x:1}}",
15033+
"@supports (selector(a)) or (x:y){a{x:1}}"
15034+
],
15035+
[
15036+
"@supports ((a:b) and (c:d)) or (-webkit-mask-image:none) or (mask-image:none){a{x:1}}",
15037+
"@supports ((a:b) and (c:d)) or (mask-image:none){a{x:1}}"
15038+
],
1502615039
[
1502715040
"@supports (-webkit-mask-image:none) or selector(a){a{x:1}}",
1502815041
"@supports (-webkit-mask-image:none) or selector(a){a{x:1}}"
@@ -15060,7 +15073,11 @@ describe("CssSyntax minify — what a comparison with other minifiers found", ()
1506015073
['a{grid-template-areas:"a";grid-template-rows:var(--r);grid-template-columns:1fr}'],
1506115074
['a{grid-template-areas:"a";grid-template-rows:1fr!important;grid-template-columns:1fr}'],
1506215075
['a{grid-template-areas:"a";grid-template-rows:1fr;grid-gap:1px;grid-template-columns:1fr}'],
15063-
["a{grid-template-areas:inherit;grid-template-rows:1fr;grid-template-columns:1fr}"]
15076+
["a{grid-template-areas:inherit;grid-template-rows:1fr;grid-template-columns:1fr}"],
15077+
// A write still read, a rule or a vendor property between.
15078+
['a{grid-template-areas:"a";grid-template-rows:1fr!important;grid-template-rows:2fr;grid-template-columns:1fr}'],
15079+
['a{grid-template-areas:"a";&:hover{x:1}grid-template-rows:1fr;grid-template-columns:1fr}'],
15080+
['a{grid-template-areas:"a";-webkit-x:1;grid-template-rows:1fr;grid-template-columns:1fr}']
1506415081
])("keeps %s apart", (css) => {
1506515082
expect(settled(css)).not.toContain("grid-template:");
1506615083
});

0 commit comments

Comments
 (0)