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
This commit is contained in:
Natalie Weizenbaum 2022-07-18 17:57:45 -07:00 committed by GitHub
parent 4b53c163d7
commit 1bd774485d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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);
}),
@ -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()
@ -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");