File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 10
10
is a ` :host ` or ` :host-context ` and the other is a selector that's guaranteed
11
11
to be within the current shadow DOM. The ` @extend ` logic has been updated
12
12
accordingly as well.
13
-
13
+
14
+ * Fix a bug where the right-hand operand of a ` - ` in a calculation could
15
+ incorrectly be stripped of parentheses.
16
+
14
17
### Dart API
15
18
16
19
* ` SassCalculation.plus() ` now allows ` SassString ` arguments.
Original file line number Diff line number Diff line change @@ -498,14 +498,25 @@ class _SerializeVisitor
498
498
var right = value.right;
499
499
var parenthesizeRight = right is CalculationInterpolation ||
500
500
(right is CalculationOperation &&
501
- (right.operator .precedence < value.operator .precedence ||
502
- value.operator == CalculationOperator .dividedBy));
501
+ _parenthesizeCalculationRhs (value.operator , right.operator ));
503
502
if (parenthesizeRight) _buffer.writeCharCode ($lparen);
504
503
_writeCalculationValue (right);
505
504
if (parenthesizeRight) _buffer.writeCharCode ($rparen);
506
505
}
507
506
}
508
507
508
+ /// Returns whether the right-hand operation of a calculation should be
509
+ /// parenthesized.
510
+ ///
511
+ /// In `a ? (b # c)` , `outer` is `?` and `right` is `#` .
512
+ bool _parenthesizeCalculationRhs (
513
+ CalculationOperator outer, CalculationOperator right) {
514
+ if (outer == CalculationOperator .dividedBy) return true ;
515
+ if (outer == CalculationOperator .plus) return false ;
516
+ return right == CalculationOperator .plus ||
517
+ right == CalculationOperator .minus;
518
+ }
519
+
509
520
void visitColor (SassColor value) {
510
521
// In compressed mode, emit colors in the shortest representation possible.
511
522
if (_isCompressed && fuzzyEquals (value.alpha, 1 )) {
You can’t perform that action at this time.
0 commit comments