From 28b3dfd111700794adb0ee8ef117fdf9a00629d5 Mon Sep 17 00:00:00 2001 From: ssssota Date: Mon, 23 Mar 2026 12:45:34 +0900 Subject: [PATCH] fix: fix minification of negative scientific notation dimensions --- src/lib.rs | 4 ++++ src/values/length.rs | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 75e8eef4b..955526517 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13207,6 +13207,10 @@ mod tests { ".foo { background: linear-gradient(135deg, yellow, blue); }", ".foo{background:linear-gradient(135deg,#ff0,#00f)}", ); + minify_test( + ".foo { background: linear-gradient(-1.42109e-14deg, rgba(10, 132, 255, 0.14) 0%, rgba(112, 183, 255, 0.14) 100%); }", + ".foo{background:linear-gradient(-1.42109e-14deg,#0a84ff24 0%,#70b7ff24 100%)}", + ); minify_test( ".foo { background: linear-gradient(yellow, blue 20%, #0f0); }", ".foo{background:linear-gradient(#ff0,#00f 20%,#0f0)}", diff --git a/src/values/length.rs b/src/values/length.rs index 2ce01b06e..f653ba9e5 100644 --- a/src/values/length.rs +++ b/src/values/length.rs @@ -499,8 +499,12 @@ where let mut s = String::new(); token.to_css(&mut s)?; if value < 0.0 { - dest.write_char('-')?; - dest.write_str(s.trim_start_matches("-0")) + if let Some(stripped) = s.strip_prefix("-0") { + dest.write_char('-')?; + dest.write_str(stripped) + } else { + dest.write_str(&s) + } } else { dest.write_str(s.trim_start_matches('0')) }