Skip to content

Commit

Permalink
Deprecate passing non-deg units to hwb()'s $hue argument (#1747)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nex3 committed Jul 19, 2022
1 parent 4b53c16 commit 1bd7744
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,8 @@

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

* Deprecate passing non-`deg` units to `color.hwb()`'s `$hue` argument.

### JS API

* Add a `charset` option that controls whether or not Sass emits a
Expand Down
5 changes: 3 additions & 2 deletions lib/src/functions/color.dart
Expand Up @@ -121,7 +121,7 @@ final global = UnmodifiableListView([
_function("adjust-hue", r"$color, $degrees", (arguments) {
var color = arguments[0].assertColor("color");
var degrees = arguments[1].assertNumber("degrees");
_checkAngle(degrees);
_checkAngle(degrees, "degrees");
return color.changeHsl(hue: color.hue + degrees.value);
}),

Expand Down Expand Up @@ -635,7 +635,7 @@ Value _hsl(String name, List<Value> arguments) {
}

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

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

_checkAngle(hue, "hue");
whiteness.assertUnit("%", "whiteness");
blackness.assertUnit("%", "blackness");

Expand Down

0 comments on commit 1bd7744

Please sign in to comment.