Skip to content

Commit

Permalink
Print the values of deprecated numbers passed to color functions (#1184)
Browse files Browse the repository at this point in the history
See #1174
  • Loading branch information
nex3 authored Jan 6, 2021
1 parent f24a2b9 commit 01231e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.32.2

* Print the actual number that was received in unit deprecation warnings for
color functions.

## 1.32.1

* Don't emit permissions errors on Windows and OS X when trying to determine the
Expand Down
13 changes: 8 additions & 5 deletions lib/src/functions/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ final module = BuiltInModule("color", functions: [

var result = _functionString("invert", arguments.take(1));
warn(
"Passing a number to color.invert() is deprecated.\n"
"Passing a number (${arguments[0]}) to color.invert() is "
"deprecated.\n"
"\n"
"Recommendation: $result",
deprecation: true);
Expand All @@ -259,7 +260,8 @@ final module = BuiltInModule("color", functions: [
if (arguments[0] is SassNumber) {
var result = _functionString("grayscale", arguments.take(1));
warn(
"Passing a number to color.grayscale() is deprecated.\n"
"Passing a number (${arguments[0]}) to color.grayscale() is "
"deprecated.\n"
"\n"
"Recommendation: $result",
deprecation: true);
Expand Down Expand Up @@ -347,7 +349,8 @@ final module = BuiltInModule("color", functions: [
if (arguments[0] is SassNumber) {
var result = _functionString("opacity", arguments);
warn(
"Passing a number to color.opacity() is deprecated.\n"
"Passing a number (${arguments[0]} to color.opacity() is "
"deprecated.\n"
"\n"
"Recommendation: $result",
deprecation: true);
Expand Down Expand Up @@ -635,7 +638,7 @@ void _checkAngle(SassNumber angle, [String name]) {
if (!angle.hasUnits || angle.hasUnit('deg')) return;

var message = StringBuffer()
..writeln("\$$name: Passing a unit other than deg is deprecated.")
..writeln("\$$name: Passing a unit other than deg ($angle) is deprecated.")
..writeln();

if (angle.compatibleWithUnit('deg')) {
Expand Down Expand Up @@ -667,7 +670,7 @@ void _checkPercent(SassNumber number, String name) {
if (number.hasUnit('%')) return;

warn(
"\$$name: Passing a number without unit % is deprecated.\n"
"\$$name: Passing a number without unit % ($number) is deprecated.\n"
"\n"
"To preserve current behavior: \$$name${_removeUnits(number)} * 1%",
deprecation: true);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.32.1
version: 1.32.2
description: A Sass implementation in Dart.
author: Sass Team
homepage: https://github.com/sass/dart-sass
Expand Down

0 comments on commit 01231e2

Please sign in to comment.