Skip to content

Commit

Permalink
Allow extra whitespace in min, max, and calculations (#1483)
Browse files Browse the repository at this point in the history
Closes #1444
  • Loading branch information
nex3 committed Sep 14, 2021
1 parent 7de7ab4 commit 30cc9dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
to be within the current shadow DOM. The `@extend` logic has been updated
accordingly as well.

* Fix a bug where extra whitespace in `min()`, `max()`, `clamp()`, and `calc()`
expressions could cause bogus parse errors.

* Fix a bug where the right-hand operand of a `-` in a calculation could
incorrectly be stripped of parentheses.

Expand Down
10 changes: 9 additions & 1 deletion lib/src/parse/stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2802,6 +2802,8 @@ abstract class StylesheetParser extends Parser {
/// productions separated by commas.
bool _tryMinMaxContents(InterpolationBuffer buffer,
{bool allowComma = true}) {
whitespace();

// The number of open parentheses that need to be closed.
while (true) {
var next = scanner.peekChar();
Expand Down Expand Up @@ -3013,7 +3015,13 @@ abstract class StylesheetParser extends Parser {
} else if (next == $lparen) {
var start = scanner.state;
scanner.readChar();
var value = _tryCalculationInterpolation() ?? _calculationSum();

Expression? value = _tryCalculationInterpolation();
if (value == null) {
whitespace();
value = _calculationSum();
}

whitespace();
scanner.expectChar($rparen);
return ParenthesizedExpression(value, scanner.spanFrom(start));
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.41.0-dev
version: 1.41.0
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit 30cc9dc

Please sign in to comment.