Skip to content

Commit aa2ed1e

Browse files
authored
Fix additionally inserted whitespace in var(--foo,) and env(--foo,) (parcel-bundler#1142)
1 parent 6993d9f commit aa2ed1e

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23106,6 +23106,22 @@ mod tests {
2310623106
minify_test(".foo { --test: .5s; }", ".foo{--test:.5s}");
2310723107
minify_test(".foo { --theme-sizes-1\\/12: 2 }", ".foo{--theme-sizes-1\\/12:2}");
2310823108
minify_test(".foo { --test: 0px; }", ".foo{--test:0px}");
23109+
test(
23110+
".foo { transform: var(--bar, ) }",
23111+
indoc! {r#"
23112+
.foo {
23113+
transform: var(--bar, );
23114+
}
23115+
"#},
23116+
);
23117+
test(
23118+
".foo { transform: env(--bar, ) }",
23119+
indoc! {r#"
23120+
.foo {
23121+
transform: env(--bar, );
23122+
}
23123+
"#},
23124+
);
2310923125

2311023126
// Test attr() function with type() syntax - minified
2311123127
minify_test(

src/properties/custom.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,10 @@ impl<'i> Variable<'i> {
12151215
dest.write_str("var(")?;
12161216
self.name.to_css(dest)?;
12171217
if let Some(fallback) = &self.fallback {
1218-
dest.delim(',', false)?;
1218+
dest.write_char(',')?;
1219+
if !fallback.starts_with_whitespace() {
1220+
dest.whitespace()?;
1221+
}
12191222
fallback.to_css(dest, is_custom_property)?;
12201223
}
12211224
dest.write_char(')')
@@ -1389,7 +1392,10 @@ impl<'i> EnvironmentVariable<'i> {
13891392
}
13901393

13911394
if let Some(fallback) = &self.fallback {
1392-
dest.delim(',', false)?;
1395+
dest.write_char(',')?;
1396+
if !fallback.starts_with_whitespace() {
1397+
dest.whitespace()?;
1398+
}
13931399
fallback.to_css(dest, is_custom_property)?;
13941400
}
13951401
dest.write_char(')')

0 commit comments

Comments
 (0)