Skip to content

Commit

Permalink
Fix extraneous trailing space for border property (#138)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lucacasonato authored Apr 5, 2022
1 parent b210549 commit 7bc3171
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/properties/border.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ impl<S: ToCss + Default + PartialEq> ToCss for GenericBorder<S> {

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(())
Expand Down

0 comments on commit 7bc3171

Please sign in to comment.