Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate passing non-deg units to hwb()'s $hue argument #1747

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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