Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Unified Diff: src/js/i18n.js

Issue 1473493003: Revert of [Intl] create new instances when new.target is undefined (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/i18n.js
diff --git a/src/js/i18n.js b/src/js/i18n.js
index 1920bbb735a8b08a64ca840bf1fc7f4f0f099ede..f2b9dd4445e6179682a48584d3c60a0acafb593f 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -947,16 +947,19 @@
*
* @constructor
*/
-function Collator() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
-
- if (IS_UNDEFINED(new.target)) return new Collator(locales, options);
-
- return initializeCollator(this, locales, options);
-}
-
-%AddNamedProperty(Intl, 'Collator', Collator, DONT_ENUM);
+%AddNamedProperty(Intl, 'Collator', function() {
+ var locales = %_Arguments(0);
+ var options = %_Arguments(1);
+
+ if (!this || this === Intl) {
+ // Constructor is called as a function.
+ return new Intl.Collator(locales, options);
+ }
+
+ return initializeCollator(TO_OBJECT(this), locales, options);
+ },
+ DONT_ENUM
+);
/**
@@ -1186,15 +1189,19 @@
*
* @constructor
*/
-function NumberFormat() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
-
- if (IS_UNDEFINED(new.target)) return new NumberFormat(locales, options);
-
- return initializeNumberFormat(this, locales, options);
-}
-%AddNamedProperty(Intl, 'NumberFormat', NumberFormat, DONT_ENUM);
+%AddNamedProperty(Intl, 'NumberFormat', function() {
+ var locales = %_Arguments(0);
+ var options = %_Arguments(1);
+
+ if (!this || this === Intl) {
+ // Constructor is called as a function.
+ return new Intl.NumberFormat(locales, options);
+ }
+
+ return initializeNumberFormat(TO_OBJECT(this), locales, options);
+ },
+ DONT_ENUM
+);
/**
@@ -1584,15 +1591,19 @@
*
* @constructor
*/
-function DateTimeFormat() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
-
- if (IS_UNDEFINED(new.target)) return new DateTimeFormat(locales, options);
-
- return initializeDateTimeFormat(this, locales, options);
-}
-%AddNamedProperty(Intl, 'DateTimeFormat', DateTimeFormat, DONT_ENUM);
+%AddNamedProperty(Intl, 'DateTimeFormat', function() {
+ var locales = %_Arguments(0);
+ var options = %_Arguments(1);
+
+ if (!this || this === Intl) {
+ // Constructor is called as a function.
+ return new Intl.DateTimeFormat(locales, options);
+ }
+
+ return initializeDateTimeFormat(TO_OBJECT(this), locales, options);
+ },
+ DONT_ENUM
+);
/**
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698