diff options
-rw-r--r-- | scss/functions/compass/gradients.py | 6 | ||||
-rw-r--r-- | scss/types.py | 13 |
2 files changed, 16 insertions, 3 deletions
diff --git a/scss/functions/compass/gradients.py b/scss/functions/compass/gradients.py index 37fd5fe..5f4d60d 100644 --- a/scss/functions/compass/gradients.py +++ b/scss/functions/compass/gradients.py @@ -62,13 +62,13 @@ def __color_stops(percentages, *args): if stops[-1] is None: stops[-1] = Number(100, '%') - maxable_stops = [s for s in stops if s and s.unit != '%'] + maxable_stops = [s for s in stops if s and not s.is_simple_unit('%')] if maxable_stops: max_stops = max(maxable_stops) else: max_stops = None - stops = [_s / max_stops if _s and _s.unit != '%' else _s for _s in stops] + stops = [_s / max_stops if _s and not _s.is_simple_unit('%') else _s for _s in stops] init = 0 start = None @@ -89,7 +89,7 @@ def __color_stops(percentages, *args): if not max_stops or percentages: pass else: - stops = [s if s.unit == '%' else s * max_stops for s in stops] + stops = [s if s.is_simple_unit('%') else s * max_stops for s in stops] return zip(stops, colors) 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 |