style: Serialize percentages first in specified calc() expressions.

This commit is contained in:
Emilio Cobos Álvarez 2017-08-17 21:38:16 +02:00
parent f8a6eccda2
commit e05c673df3
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -125,6 +125,13 @@ impl ToCss for CalcLengthOrPercentage {
dest.write_str("calc(")?;
// NOTE(emilio): Percentages first because of web-compat problems, see:
// https://github.com/w3c/csswg-drafts/issues/1731
if let Some(val) = self.percentage {
first_value_check!(val.0);
val.abs().to_css(dest)?;
}
// NOTE(emilio): The order here it's very intentional, and alphabetic
// per the spec linked above.
serialize!(ch, em, ex);
@ -143,11 +150,6 @@ impl ToCss for CalcLengthOrPercentage {
serialize!(rem, vh, vmax, vmin, vw);
if let Some(val) = self.percentage {
first_value_check!(val.0);
val.abs().to_css(dest)?;
}
dest.write_str(")")
}
}