Skip to content

Commit

Permalink
Throw proper errors for out-of-range alpha values in color.change() (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed May 2, 2024
1 parent 09fd9c2 commit ce124ba
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/src/functions/color.dart
Expand Up @@ -762,9 +762,10 @@ SassColor _changeColor(
_channelForChange(channelArgs[2], color, 2),
alphaArg.andThen((alphaArg) {
if (!alphaArg.hasUnits) {
return alphaArg.value;
return alphaArg.valueInRange(0, 1, "alpha");
} else if (alphaArg.hasUnit('%')) {
return alphaArg.value / 100;
return alphaArg.valueInRangeWithUnit(0, 100, "alpha", "%") /
100;
} else {
warnForDeprecation(
"\$alpha: Passing a unit other than % ($alphaArg) is "
Expand All @@ -775,7 +776,7 @@ SassColor _changeColor(
"\n"
"See https://sass-lang.com/d/function-units",
Deprecation.functionUnits);
return alphaArg.value;
return alphaArg.valueInRange(0, 1, "alpha");
}
}) ??
color.alpha,
Expand Down

0 comments on commit ce124ba

Please sign in to comment.