Skip to content

Commit

Permalink
Allow the + operator for calculations and strings (#1481)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Sep 14, 2021
1 parent fe46cbb commit 5e4bc45
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
## 1.40.2
## 1.41.0

* Calculation values can now be combined with strings using the `+` operator.
This was an error in 1.40.0, but this broke stylesheets that were relying on
`$value + ""` expressions to generically convert values to strings. (Note that
the Sass team recommends the use of `"#{$value}"` or `inspect($value)` for
that use-case.)

* The `selector.unify()` function now correctly returns `null` when one selector
is a `:host` or `:host-context` and the other is a selector that's guaranteed
to be within the current shadow DOM. The `@extend` logic has been updated
accordingly as well.

### Dart API

* `SassCalculation.plus()` now allows `SassString` arguments.

## 1.40.1

Expand Down
6 changes: 4 additions & 2 deletions lib/src/value/calculation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,10 @@ class SassCalculation extends Value {

/// @nodoc
@internal
Value plus(Value other) =>
throw SassScriptException('Undefined operation "$this + $other".');
Value plus(Value other) {
if (other is SassString) return super.plus(other);
throw SassScriptException('Undefined operation "$this + $other".');
}

/// @nodoc
@internal
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0-beta.11

* No user-visible changes.

## 1.0.0-beta.10

* No user-visible changes.
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: 1.0.0-beta.10
version: 1.0.0-beta.11
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
sass: 1.40.1
sass: 1.41.0

dependency_overrides:
sass: {path: ../..}
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.40.2-dev
version: 1.41.0-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit 5e4bc45

Please sign in to comment.