summaryrefslogtreecommitdiff
path: root/scss/types.py
diff options
context:
space:
mode:
Diffstat (limited to 'scss/types.py')
-rw-r--r--scss/types.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/scss/types.py b/scss/types.py
index 320dc38..01335c5 100644
--- a/scss/types.py
+++ b/scss/types.py
@@ -471,6 +471,19 @@ class Number(Value):
"""
return len(self.unit_numer) <= 1 and not self.unit_denom
+ def is_simple_unit(self, unit):
+ """Return True iff the unit is simple (as above) and matches the given
+ unit.
+ """
+ if self.unit_denom or len(self.unit_numer) > 1:
+ return False
+
+ if not self.unit_numer:
+ # Empty string historically means no unit
+ return unit == ''
+
+ return self.unit_numer[0] == unit
+
@property
def is_unitless(self):
return not self.unit_numer and not self.unit_denom