Skip to content

Commit

Permalink
Update pubspec and changelog and re-add abs-percent deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Aug 17, 2023
1 parent 458852d commit a6a06b7
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/src/deprecation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 24 additions & 7 deletions lib/src/functions/math.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Callable>[
_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),
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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

environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
sass: 1.64.3
sass: 1.66.0

dev_dependencies:
dartdoc: ^5.0.0
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.64.3
version: 1.66.0
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit a6a06b7

Please sign in to comment.