Skip to content

Commit

Permalink
Round accepting fake units fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelalozano16 committed Jul 21, 2023
1 parent 78460f4 commit 4d38e3b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/node/value/calculation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ final JSClass calculationOperationClass = () {
_assertCalculationValue(left);
_assertCalculationValue(right);
return SassCalculation.operateInternal(operator, left, right,
inMinMax: false, simplify: false);
inLegacySassFunction: false, simplify: false);
});

jsClass.defineMethods({
Expand All @@ -109,7 +109,7 @@ final JSClass calculationOperationClass = () {

getJSClass(SassCalculation.operateInternal(
CalculationOperator.plus, SassNumber(1), SassNumber(1),
inMinMax: false, simplify: false))
inLegacySassFunction: false, simplify: false))
.injectSuperclass(jsClass);
return jsClass;
}();
Expand Down
15 changes: 15 additions & 0 deletions lib/src/value/calculation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,25 @@ class SassCalculation extends Value {
case (SassNumber number, null, null):
return _matchUnits(number.value.round().toDouble(), number);

case (SassNumber number, SassNumber step, null)
when (!number.hasCompatibleUnits(step)):
_verifyCompatibleNumbers([number, step]);
return SassCalculation._("round", [number, step]);

case (SassNumber number, SassNumber step, null):
_verifyCompatibleNumbers([number, step]);
return _roundWithStep('nearest', number, step);

case (
SassString(text: 'nearest' || 'up' || 'down' || 'to-zero') &&
var strategy,
SassNumber number,
SassNumber step
)
when (!number.hasCompatibleUnits(step)):
_verifyCompatibleNumbers([number, step]);
return SassCalculation._("round", [strategy, number, step]);

case (
SassString(text: 'nearest' || 'up' || 'down' || 'to-zero') &&
var strategy,
Expand Down

0 comments on commit 4d38e3b

Please sign in to comment.