diff --git a/CHANGELOG.md b/CHANGELOG.md index 929d0f83..59365084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ command-line interface, Dart API, and JS API. These load paths are checked just after the load paths explicitly passed by the user. +* Allow saturation and lightness values outside of the `0%` to `100%` range in + the `hsl()` and `hsla()` functions. They're now clamped to be within that + range rather than producing an error if they're outside it. + * Properly compile selectors that end in escaped whitespace. [content-args]: https://github.com/sass/language/blob/master/accepted/content-args.md diff --git a/lib/src/functions.dart b/lib/src/functions.dart index 0f95463d..0fc1e547 100644 --- a/lib/src/functions.dart +++ b/lib/src/functions.dart @@ -174,7 +174,8 @@ final List coreFunctions = new UnmodifiableListView([ var saturation = arguments[1].assertNumber("saturation"); var lightness = arguments[2].assertNumber("lightness"); - return new SassColor.hsl(hue.value, saturation.value, lightness.value); + return new SassColor.hsl(hue.value, saturation.value.clamp(0, 100), + lightness.value.clamp(0, 100)); }, r"$hue, $saturation": (arguments) { // hsl(123, var(--foo)) is valid CSS because --foo might be `10%, 20%` and @@ -208,7 +209,10 @@ final List coreFunctions = new UnmodifiableListView([ var lightness = arguments[2].assertNumber("lightness"); var alpha = arguments[3].assertNumber("alpha"); - return new SassColor.hsl(hue.value, saturation.value, lightness.value, + return new SassColor.hsl( + hue.value, + saturation.value.clamp(0, 100), + lightness.value.clamp(0, 100), _percentageOrUnitless(alpha, 1, "alpha")); }, r"$hue, $saturation, $lightness": (arguments) {