Skip to content

Commit 1bd7744

Browse files
authored
Deprecate passing non-deg units to hwb()'s $hue argument (#1747)
This was overlooked in #1175, because the spec said that `hwb()` should already be throwing an error if non-`deg` units were passed. However, Dart Sass didn't implement the spec correctly and these units were in fact not being checked at all. See #1174
1 parent 4b53c16 commit 1bd7744

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
See https://sass-lang.com/d/bogus-combinators for more details.
1010

11+
* Deprecate passing non-`deg` units to `color.hwb()`'s `$hue` argument.
12+
1113
### JS API
1214

1315
* Add a `charset` option that controls whether or not Sass emits a

lib/src/functions/color.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ final global = UnmodifiableListView([
121121
_function("adjust-hue", r"$color, $degrees", (arguments) {
122122
var color = arguments[0].assertColor("color");
123123
var degrees = arguments[1].assertNumber("degrees");
124-
_checkAngle(degrees);
124+
_checkAngle(degrees, "degrees");
125125
return color.changeHsl(hue: color.hue + degrees.value);
126126
}),
127127

@@ -635,7 +635,7 @@ Value _hsl(String name, List<Value> arguments) {
635635
}
636636

637637
/// Prints a deprecation warning if [hue] has a unit other than `deg`.
638-
void _checkAngle(SassNumber angle, [String? name]) {
638+
void _checkAngle(SassNumber angle, String name) {
639639
if (!angle.hasUnits || angle.hasUnit('deg')) return;
640640

641641
var message = StringBuffer()
@@ -692,6 +692,7 @@ Value _hwb(List<Value> arguments) {
692692
var whiteness = arguments[1].assertNumber("whiteness");
693693
var blackness = arguments[2].assertNumber("blackness");
694694

695+
_checkAngle(hue, "hue");
695696
whiteness.assertUnit("%", "whiteness");
696697
blackness.assertUnit("%", "blackness");
697698

0 commit comments

Comments
 (0)