From f4b6cee0ccfb91123b5a141ec70ab9b3a47fac37 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 1 Jul 2024 23:43:24 +0200 Subject: [PATCH] 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 --- js/src/jsnum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index beff701bd0..598cf7caf0 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -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; }