Skip to content

Commit 30cc9dc

Browse files
authored
Allow extra whitespace in min, max, and calculations (#1483)
Closes #1444
1 parent 7de7ab4 commit 30cc9dc

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
to be within the current shadow DOM. The `@extend` logic has been updated
1212
accordingly as well.
1313

14+
* Fix a bug where extra whitespace in `min()`, `max()`, `clamp()`, and `calc()`
15+
expressions could cause bogus parse errors.
16+
1417
* Fix a bug where the right-hand operand of a `-` in a calculation could
1518
incorrectly be stripped of parentheses.
1619

lib/src/parse/stylesheet.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2802,6 +2802,8 @@ abstract class StylesheetParser extends Parser {
28022802
/// productions separated by commas.
28032803
bool _tryMinMaxContents(InterpolationBuffer buffer,
28042804
{bool allowComma = true}) {
2805+
whitespace();
2806+
28052807
// The number of open parentheses that need to be closed.
28062808
while (true) {
28072809
var next = scanner.peekChar();
@@ -3013,7 +3015,13 @@ abstract class StylesheetParser extends Parser {
30133015
} else if (next == $lparen) {
30143016
var start = scanner.state;
30153017
scanner.readChar();
3016-
var value = _tryCalculationInterpolation() ?? _calculationSum();
3018+
3019+
Expression? value = _tryCalculationInterpolation();
3020+
if (value == null) {
3021+
whitespace();
3022+
value = _calculationSum();
3023+
}
3024+
30173025
whitespace();
30183026
scanner.expectChar($rparen);
30193027
return ParenthesizedExpression(value, scanner.spanFrom(start));

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.41.0-dev
2+
version: 1.41.0
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)