abs static method
Creates an abs()
calculation with the given argument
.
The argument
must be either a SassNumber, a SassCalculation, an
unquoted SassString, or a CalculationOperation.
This automatically simplifies the calculation, so it may return a SassNumber rather than a SassCalculation. It throws an exception if it can determine that the calculation will definitely produce invalid CSS.
Implementation
static Value abs(Object argument) {
argument = _simplify(argument);
if (argument is! SassNumber) return SassCalculation._("abs", [argument]);
if (argument.hasUnit("%")) {
warnForDeprecation(
"Passing percentage units to the global abs() function is deprecated.\n"
"In the future, this will emit a CSS abs() function to be resolved by the browser.\n"
"To preserve current behavior: math.abs($argument)"
"\n"
"To emit a CSS abs() now: abs(#{$argument})\n"
"More info: https://sass-lang.com/d/abs-percent",
Deprecation.absPercent);
}
return number_lib.abs(argument);
}