From ec9a0ce6fd8c7549a307d27f4f738efeec72cc02 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 5 Apr 2022 01:41:14 +0200 Subject: [PATCH] Fix extraneous trailing space for border property If just color, or color and style for a border were ommited, an extraneous space char would be present at the end of the property value output. This commit fixes this by inserting spaces before values rather than after. --- src/lib.rs | 23 +++++++++++++++++++++++ src/properties/border.rs | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bf254697..28fa8f04 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -759,6 +759,29 @@ mod tests { "#}, ); + test( + r#" + .foo { + border: 1px solid currentColor; + } + "#, + indoc! {r#" + .foo { + border: 1px solid; + } + "# + }, + ); + + minify_test( + r#" + .foo { + border: 1px solid currentColor; + } + "#, + ".foo{border:1px solid}", + ); + prefix_test( r#" .foo { diff --git a/src/properties/border.rs b/src/properties/border.rs index e9e2dc9b..bf5f7bb0 100644 --- a/src/properties/border.rs +++ b/src/properties/border.rs @@ -162,13 +162,13 @@ impl ToCss for GenericBorder { if self.width != BorderSideWidth::default() { self.width.to_css(dest)?; - dest.write_str(" ")?; } if self.style != S::default() { - self.style.to_css(dest)?; dest.write_str(" ")?; + self.style.to_css(dest)?; } if self.color != CssColor::current_color() { + dest.write_str(" ")?; self.color.to_css(dest)?; } Ok(())