properly emit 0 in compressed mode
This commit is contained in:
parent
537ba67cc9
commit
a6eb1fb88a
@ -444,15 +444,24 @@ impl Number {
|
||||
}
|
||||
}
|
||||
|
||||
if self.is_negative() && (!whole.is_zero() || !dec.is_empty()) {
|
||||
let has_decimal = !dec.is_empty();
|
||||
|
||||
if self.is_negative() && (!whole.is_zero() || has_decimal) {
|
||||
buf.push('-');
|
||||
}
|
||||
|
||||
if !(whole.is_zero() && is_compressed) {
|
||||
// if the entire number is just zero, we always want to emit it
|
||||
if whole.is_zero() && !has_decimal {
|
||||
return "0".to_owned();
|
||||
|
||||
// otherwise, if the number is not 0, or the number before the decimal
|
||||
// _is_ 0 and we aren't in compressed mode, emit the number before the
|
||||
// decimal
|
||||
} else if !(whole.is_zero() && is_compressed) {
|
||||
buf.push_str(&whole.to_string());
|
||||
}
|
||||
|
||||
if !dec.is_empty() {
|
||||
if has_decimal {
|
||||
buf.push('.');
|
||||
buf.push_str(&dec);
|
||||
}
|
||||
|
@ -116,3 +116,9 @@ test!(
|
||||
"a{color:grayscale(0.5)}",
|
||||
grass::Options::default().style(grass::OutputStyle::Compressed)
|
||||
);
|
||||
test!(
|
||||
retains_zero_without_decimal,
|
||||
"a {\n color: 0.0;\n color: 0;\n}\n",
|
||||
"a{color:0;color:0}",
|
||||
grass::Options::default().style(grass::OutputStyle::Compressed)
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user