Skip to content

Commit a28dbc7

Browse files
fix(css): read a block's at-rule name with the shared helper when ordering declarations
#22569 removed path.atKeyword while the declaration order change was in review, so minifying any at-rule holding declarations, such as @font-face, threw. Read the name with _atKeywordOf, as the rest of the printer does.
1 parent 8953192 commit a28dbc7

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎lib/css/syntax-parser.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17598,7 +17598,7 @@ const _composeBlockBody = (
1759817598
items.length > 1 &&
1759917599
owner !== null &&
1760017600
(path.type(owner) === T_QUALIFIED_RULE ||
17601-
_NESTED_GROUP_AT_RULES.has(path.atKeyword(owner))) &&
17601+
_NESTED_GROUP_AT_RULES.has(_atKeywordOf(owner))) &&
1760217602
_writesOnlyDeclarations(path, items, texts)
1760317603
? []
1760417604
: null;

‎test/unitCases/CssSyntax.unittest.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15494,6 +15494,10 @@ describe("CssSyntax minify — declaration order", () => {
1549415494
// A nested rule that prints nothing is no rule the order has to keep.
1549515495
["a{display:block;color:red;& b{}}", "a{color:red;display:block}"],
1549615496
["@keyframes k{0%{transform:none;opacity:0}}", "@keyframes k{0%{opacity:0;transform:none}}"],
15497+
// A group rule nested in a style rule holds that rule's declarations.
15498+
["a{@media (min-width:1px){display:block;color:red}}", "a{@media (width>=1px){color:red;display:block}}"],
15499+
// An at-rule's own descriptors are no style rule's declarations.
15500+
["@font-face{src:url(a.woff);font-family:a}", "@font-face{src:url(a.woff);font-family:a}"],
1549715501
// Within a family, in the order written.
1549815502
[
1549915503
"a{transition-delay:1s;transition-property:opacity;height:0;width:0}",

0 commit comments

Comments
 (0)