From a6a06b7eecf46e1ff8c378c6a262612b1008524f Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 17 Aug 2023 11:26:46 -0700 Subject: [PATCH] Update pubspec and changelog and re-add abs-percent deprecation --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ lib/src/deprecation.dart | 5 +++++ lib/src/functions/math.dart | 31 ++++++++++++++++++++++++------- pkg/sass_api/CHANGELOG.md | 12 ++++++++++++ pkg/sass_api/pubspec.yaml | 4 ++-- pubspec.yaml | 2 +- 6 files changed, 71 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de3e450d6..3270acbcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +## 1.66.0 + +* **Breaking change:** Drop support for the additional CSS calculations defined + in CSS Values and Units 4. Custom Sass functions whose names overlapped with + these new CSS functions were being parsed as CSS calculations instead, causing + an unintentional breaking change outside our normal [compatibility policy] for + CSS compatibility changes. + + Support will be added again in a future version, but only after Sass has + emitted a deprecation warning for all functions that will break for at least + three months prior to the breakage. + +## 1.65.1 + +* Update abs-percent deprecatedIn version to `1.65.0`. + +## 1.65.0 + +* All functions defined in CSS Values and Units 4 are now parsed as calculation + objects: `round()`, `mod()`, `rem()`, `sin()`, `cos()`, `tan()`, `asin()`, + `acos()`, `atan()`, `atan2()`, `pow()`, `sqrt()`, `hypot()`, `log()`, `exp()`, + `abs()`, and `sign()`. + +* Deprecate explicitly passing the `%` unit to the global `abs()` function. In + future releases, this will emit a CSS abs() function to be resolved by the + browser. This deprecation is named `abs-percent`. + ## 1.64.3 ### Dart API diff --git a/lib/src/deprecation.dart b/lib/src/deprecation.dart index 8e6f6174d..5ea363008 100644 --- a/lib/src/deprecation.dart +++ b/lib/src/deprecation.dart @@ -55,6 +55,11 @@ enum Deprecation { deprecatedIn: '1.56.0', description: 'Passing invalid units to built-in functions.'), + /// Deprecation for passing percentages to the Sass abs() function. + absPercent('abs-percent', + deprecatedIn: '1.65.0', + description: 'Passing percentages to the Sass abs() function.'), + duplicateVariableFlags('duplicate-var-flags', deprecatedIn: '1.62.0', description: diff --git a/lib/src/functions/math.dart b/lib/src/functions/math.dart index 5b7fa15f5..a85e5b1a4 100644 --- a/lib/src/functions/math.dart +++ b/lib/src/functions/math.dart @@ -16,17 +16,36 @@ import '../value.dart'; /// The global definitions of Sass math functions. final global = UnmodifiableListView([ - _abs, _ceil, _floor, _max, _min, _percentage, _randomFunction, _round, - _unit, // + _function("abs", r"$number", (arguments) { + var number = arguments[0].assertNumber("number"); + if (number.hasUnit("%")) { + warnForDeprecation( + "Passing percentage units to the global abs() function is " + "deprecated.\n" + "In the future, this will emit a CSS abs() function to be resolved " + "by the browser.\n" + "To preserve current behavior: math.abs($number)" + "\n" + "To emit a CSS abs() now: abs(#{$number})\n" + "More info: https://sass-lang.com/d/abs-percent", + Deprecation.absPercent); + } + return SassNumber.withUnits(number.value.abs(), + numeratorUnits: number.numeratorUnits, + denominatorUnits: number.denominatorUnits); + }), + + _ceil, _floor, _max, _min, _percentage, _randomFunction, _round, _unit, // _compatible.withName("comparable"), _isUnitless.withName("unitless"), ]); /// The Sass math module. final module = BuiltInModule("math", functions: [ - _abs, _acos, _asin, _atan, _atan2, _ceil, _clamp, _cos, _compatible, // - _floor, _hypot, _isUnitless, _log, _max, _min, _percentage, _pow, // - _randomFunction, _round, _sin, _sqrt, _tan, _unit, _div + _numberFunction("abs", (value) => value.abs()), + _acos, _asin, _atan, _atan2, _ceil, _clamp, _cos, _compatible, _floor, // + _hypot, _isUnitless, _log, _max, _min, _percentage, _pow, _randomFunction, + _round, _sin, _sqrt, _tan, _unit, _div ], variables: { "e": SassNumber(math.e), "pi": SassNumber(math.pi), @@ -88,8 +107,6 @@ final _round = _numberFunction("round", (number) => number.round().toDouble()); /// Distance functions /// -final _abs = _numberFunction("abs", (value) => value.abs()); - final _hypot = _function("hypot", r"$numbers...", (arguments) { var numbers = arguments[0].asList.map((argument) => argument.assertNumber()).toList(); diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index da3a1c94d..bf4003b9c 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,15 @@ +## 8.2.0 + +* No user-visible changes. + +## 8.1.1 + +* No user-visible changes. + +## 8.1.0 + +* No user-visible changes. + ## 8.0.0 * Various classes now use Dart 3 [class modifiers] to more specifically restrict diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index 3fe0ab0f6..dcf7ca03d 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ name: sass_api # Note: Every time we add a new Sass AST node, we need to bump the *major* # version because it's a breaking change for anyone who's implementing the # visitor interface(s). -version: 8.0.0 +version: 8.2.0 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - sass: 1.64.3 + sass: 1.66.0 dev_dependencies: dartdoc: ^5.0.0 diff --git a/pubspec.yaml b/pubspec.yaml index 4c22ad22e..6c34677db 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.64.3 +version: 1.66.0 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass