From 4d38e3b132dd8b4751c8d1f5d23869593b49a146 Mon Sep 17 00:00:00 2001 From: Pamela Lozano De La Garza Date: Thu, 20 Jul 2023 19:34:48 -0700 Subject: [PATCH] Round accepting fake units fix --- lib/src/node/value/calculation.dart | 4 ++-- lib/src/value/calculation.dart | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/src/node/value/calculation.dart b/lib/src/node/value/calculation.dart index ae3a8bd88..b51122348 100644 --- a/lib/src/node/value/calculation.dart +++ b/lib/src/node/value/calculation.dart @@ -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({ @@ -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; }(); diff --git a/lib/src/value/calculation.dart b/lib/src/value/calculation.dart index a5b749453..4dfd18fcc 100644 --- a/lib/src/value/calculation.dart +++ b/lib/src/value/calculation.dart @@ -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,