Skip to content

Commit b2f2532

Browse files
authored
Don't evaluate if() values if the condition doesn't match (#2707)
See sass/sass#3886 (comment)
1 parent 0c7083a commit b2f2532

File tree

8 files changed

+24
-13
lines changed

8 files changed

+24
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.97.1
2+
3+
* Fix a bug with the new CSS-style `if()` syntax where values would be evaluated
4+
even if their conditions didn't match.
5+
16
## 1.97.0
27

38
* Add support for the `display-p3-linear` color space.

lib/src/visitor/async_evaluate.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,17 +2839,16 @@ final class _EvaluateVisitor
28392839
List<(String, Value)>? results;
28402840
for (var (condition, expression) in node.branches) {
28412841
var result = await condition?.accept(this) ?? true;
2842-
var value = await expression.accept(this);
28432842
switch (result) {
28442843
case String condition:
28452844
results ??= [];
2846-
results.add((condition, value));
2845+
results.add((condition, await expression.accept(this)));
28472846

28482847
case true when results != null:
2849-
results.add(('else', value));
2848+
results.add(('else', await expression.accept(this)));
28502849

28512850
case true:
2852-
return value;
2851+
return await expression.accept(this);
28532852
}
28542853
}
28552854

lib/src/visitor/evaluate.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// DO NOT EDIT. This file was generated from async_evaluate.dart.
66
// See tool/grind/synchronize.dart for details.
77
//
8-
// Checksum: aa53924147f65640b94768e22bb339b0d5c5714a
8+
// Checksum: 72b4168ae534c17a0a5f083209fddab3646dc6b7
99
//
1010
// ignore_for_file: unused_import
1111

@@ -2842,17 +2842,16 @@ final class _EvaluateVisitor
28422842
List<(String, Value)>? results;
28432843
for (var (condition, expression) in node.branches) {
28442844
var result = condition?.accept(this) ?? true;
2845-
var value = expression.accept(this);
28462845
switch (result) {
28472846
case String condition:
28482847
results ??= [];
2849-
results.add((condition, value));
2848+
results.add((condition, expression.accept(this)));
28502849

28512850
case true when results != null:
2852-
results.add(('else', value));
2851+
results.add(('else', expression.accept(this)));
28532852

28542853
case true:
2855-
return value;
2854+
return expression.accept(this);
28562855
}
28572856
}
28582857

pkg/sass-parser/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.40
2+
3+
* No user-visible changes.
4+
15
## 0.4.39
26

37
* No user-visible changes.

pkg/sass-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-parser",
3-
"version": "0.4.39",
3+
"version": "0.4.40",
44
"description": "A PostCSS-compatible wrapper of the official Sass parser",
55
"repository": "sass/dart-sass",
66
"author": "Google Inc.",

pkg/sass_api/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 17.3.1
2+
3+
* No user-visible changes.
4+
15
## 17.3.0
26

37
* Add the `SassColor.displayP3Linear` constructor.

pkg/sass_api/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 17.3.0
5+
version: 17.3.1
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
1010
sdk: ">=3.6.0 <4.0.0"
1111

1212
dependencies:
13-
sass: 1.97.0
13+
sass: 1.97.1
1414

1515
dev_dependencies:
1616
dartdoc: ">=8.0.14 <10.0.0"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.97.0
2+
version: 1.97.1
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)