Skip to content

Commit

Permalink
Stop using Number.prototype.toLocaleString() for numeric console form…
Browse files Browse the repository at this point in the history
…at specifiers

https://bugs.webkit.org/show_bug.cgi?id=259146

Reviewed by Patrick Angle.

`console.log("%i", 1000)` should have the same output as `console.log("1000")`.

* Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype._formatWithSubstitutionString.floatFormatter):
(WI.ConsoleMessageView.prototype._formatWithSubstitutionString.integerFormatter):
Remove calling `Number.prototype.toLocaleString` as that can insert unwanted text (e.g. commas).

Canonical link: https://commits.webkit.org/266020@main
  • Loading branch information
dcrousso committed Jul 13, 2023
1 parent 8afe94a commit ae256c9
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -809,14 +809,12 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object

function floatFormatter(obj, token)
{
let value = typeof obj.value === "number" ? obj.value : obj.description;
return String.standardFormatters.f(value, token);
return parseFloat(typeof obj.value === "number" ? obj.value : obj.description).maxDecimals(token.precision);
}

function integerFormatter(obj)
{
let value = typeof obj.value === "number" ? obj.value : obj.description;
return String.standardFormatters.d(value);
return parseInt(typeof obj.value === "number" ? obj.value : obj.description);
}

var currentStyle = null;
Expand Down

0 comments on commit ae256c9

Please sign in to comment.