Skip to content

Commit 443911d

Browse files
fix(css): keep a z translation's 0% term, which makes the declaration invalid
1 parent 136b816 commit 443911d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎lib/css/syntax-printer.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5001,6 +5001,11 @@ const printer = (path, writer) => {
50015001
const args = _splitTopLevelArguments(inner);
50025002
let changed = false;
50035003
for (let i = 0; i < args.length; i++) {
5004+
// A z slot takes no percentage, so a `0%` there makes the whole
5005+
// declaration invalid, which dropping it would revive.
5006+
if (fn === "translatez" || (fn === "translate3d" && i === 2)) {
5007+
continue;
5008+
}
50045009
const term = _dropZeroPercentTerm(args[i].trim());
50055010
if (term !== null) {
50065011
args[i] = term;

‎test/unitCases/CssSyntax.unittest.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15173,6 +15173,12 @@ describe("CssSyntax minify — what a comparison with other minifiers found", ()
1517315173
["a{transform:translate(calc(0% + 1px),calc(0% - -2px))}", "a{transform:translate(1px,2px)}"],
1517415174
["a{transform:translateY(calc(5px - 0%))}", "a{transform:translateY(5px)}"],
1517515175
["a{transform:translate3d(calc(0% - 16px),0,0)}", "a{transform:translate(-16px)}"],
15176+
// A z slot takes no percentage: the declaration is invalid and stays so.
15177+
["a{transform:translateZ(calc(0% + 1px))}", "a{transform:translateZ(calc(0% + 1px))}"],
15178+
[
15179+
"a{transform:translate3d(calc(0% + 1px),0,calc(0% + 2px))}",
15180+
"a{transform:translate3d(1px,0,calc(0% + 2px))}"
15181+
],
1517615182
// The digits a second pass would find, found on the first.
1517715183
["a{max-height:89.99785714em}", "a{max-height:89.997857em}"],
1517815184
// A lone basis means `1 1 <basis>`, however the three were written.

0 commit comments

Comments
 (0)