handle percent op none
This commit is contained in:
parent
8a600a4f07
commit
bb87d4f4c0
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user