Clamp $alpha in adjust-color() with HSL args

Closes #708
This commit is contained in:
Natalie Weizenbaum 2019-07-02 16:03:44 -07:00
parent 7bfba04b79
commit 2105a138c0
2 changed files with 4 additions and 1 deletions

View File

@ -16,6 +16,9 @@
[plain-CSS invert]: https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/invert
* The `adjust-color()` function no longer throws an error when a large `$alpha`
value is combined with HSL adjustments.
* The `alpha()` function now produces clearer error messages when the wrong
number of arguments are passed.

View File

@ -414,7 +414,7 @@ final _adjust = BuiltInCallable("adjust", r"$color, $kwargs...", (arguments) {
hue: color.hue + (hue ?? 0),
saturation: (color.saturation + (saturation ?? 0)).clamp(0, 100),
lightness: (color.lightness + (lightness ?? 0)).clamp(0, 100),
alpha: color.alpha + (alpha ?? 0));
alpha: (color.alpha + (alpha ?? 0)).clamp(0, 1));
} else if (alpha != null) {
return color.changeAlpha((color.alpha + (alpha ?? 0)).clamp(0, 1));
} else {