diff --git a/CHANGELOG.md b/CHANGELOG.md index b176f180..798c12ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index 9bc13f97..678710fc 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -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(); @@ -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)); diff --git a/pubspec.yaml b/pubspec.yaml index 55f85528..4a38f57d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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