Issue #2543 - adjust toFixed precision range according to spec update.

As pointed out in the ecma-262 spec change discussion, the behavior is
inconsistent for negative numbers because the exponential fallback assumes
all the digits will be displayed. The negative support was motivated just
by consistency, without any particular concrete use cases, and it's not
supported in other browsers, so this patch removes negatives.

Resolves #2543
This commit is contained in:
Moonchild 2024-07-01 23:43:24 +02:00 committed by roytam1
commit f4b6cee0cc

View file

@ -848,7 +848,7 @@ num_toFixed_impl(JSContext* cx, const CallArgs& args)
if (!ToInteger(cx, args[0], &prec))
return false;
if (!ComputePrecisionInRange(cx, -20, MAX_PRECISION, prec, &precision))
if (!ComputePrecisionInRange(cx, 0, MAX_PRECISION, prec, &precision))
return false;
}