mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-27 04:34:59 +01:00
Clamp saturation and lightness rather than throwing errors (#521)
This matches Ruby Sass's behavior.
This commit is contained in:
parent
4520b8b53b
commit
13006e9902
@ -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
|
||||
|
@ -174,7 +174,8 @@ final List<BuiltInCallable> 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<BuiltInCallable> 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user