From bb87d4f4c07e62706a5961629953d40def0be992 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Tue, 31 Mar 2020 02:10:22 -0400 Subject: [PATCH] handle percent op none --- src/unit/mod.rs | 5 ++++- tests/units.rs | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/unit/mod.rs b/src/unit/mod.rs index 43912a4..6f6ea51 100644 --- a/src/unit/mod.rs +++ b/src/unit/mod.rs @@ -114,10 +114,13 @@ pub(crate) enum UnitKind { impl Unit { pub fn comparable(&self, other: &Unit) -> bool { + if other == &Unit::None { + return true; + } match self.kind() { UnitKind::FontRelative | UnitKind::ViewportRelative | UnitKind::Other => self == other, UnitKind::None => true, - u => other.kind() == u || other.kind() == UnitKind::None, + u => other.kind() == u, } } diff --git a/tests/units.rs b/tests/units.rs index 3116878..9665384 100644 --- a/tests/units.rs +++ b/tests/units.rs @@ -64,6 +64,11 @@ test!( "a {\n color: 10 - 10px;\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 { ($u1:ident, $u2:ident, $out:literal) => {