handle percent op none

This commit is contained in:
ConnorSkees 2020-03-31 02:10:22 -04:00
parent 8a600a4f07
commit bb87d4f4c0
2 changed files with 9 additions and 1 deletions

View File

@ -114,10 +114,13 @@ pub(crate) enum UnitKind {
impl Unit { impl Unit {
pub fn comparable(&self, other: &Unit) -> bool { pub fn comparable(&self, other: &Unit) -> bool {
if other == &Unit::None {
return true;
}
match self.kind() { match self.kind() {
UnitKind::FontRelative | UnitKind::ViewportRelative | UnitKind::Other => self == other, UnitKind::FontRelative | UnitKind::ViewportRelative | UnitKind::Other => self == other,
UnitKind::None => true, UnitKind::None => true,
u => other.kind() == u || other.kind() == UnitKind::None, u => other.kind() == u,
} }
} }

View File

@ -64,6 +64,11 @@ test!(
"a {\n color: 10 - 10px;\n}\n", "a {\n color: 10 - 10px;\n}\n",
"a {\n color: 0px;\n}\n" "a {\n color: 0px;\n}\n"
); );
test!(
percent_plus_none,
"a {\n color: 10% + 10;\n}\n",
"a {\n color: 20%;\n}\n"
);
macro_rules! test_unit_addition { macro_rules! test_unit_addition {
($u1:ident, $u2:ident, $out:literal) => { ($u1:ident, $u2:ident, $out:literal) => {