Remove ToObject on elements from Array.prototype.toLocaleString()

In ES5, ToObject was called on elements before invoking the
.toLocaleString() method on them. ES2015 specifies that ToObject is
not called. A test262 test verifies this change. This patch
implements the new ES2015 behavior. It is verified by the test262 test
built-ins/Array/prototype/toLocaleString/primitive_this_value_getter

R=adamk

Review URL: https://codereview.chromium.org/1390893003

Cr-Commit-Position: refs/heads/master@{#31160}
This commit is contained in:
littledan 2015-10-07 11:18:56 -07:00 committed by Commit bot
parent eeaf80cd86
commit 80aa6a5f7f

View File

@ -217,11 +217,7 @@ function ConvertToLocaleString(e) {
if (IS_NULL_OR_UNDEFINED(e)) { if (IS_NULL_OR_UNDEFINED(e)) {
return ''; return '';
} else { } else {
// According to ES5, section 15.4.4.3, the toLocaleString conversion return TO_STRING(e.toLocaleString());
// must throw a TypeError if ToObject(e).toLocaleString isn't
// callable.
var e_obj = TO_OBJECT(e);
return TO_STRING(e_obj.toLocaleString());
} }
} }