Allow extra whitespace in min, max, and calculations (#1483)

Closes sass/dart-sass#1444
This commit is contained in:
Natalie Weizenbaum 2021-09-14 23:03:06 +00:00 committed by GitHub
parent 7de7ab405d
commit 30cc9dcbfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -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.

View File

@ -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));

View File

@ -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