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

Unified Diff: src/js/i18n.js

Issue 1440593003: [Intl] create new instances when new.target is undefined (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove unwanted tests 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 f2b9dd4445e6179682a48584d3c60a0acafb593f..1920bbb735a8b08a64ca840bf1fc7f4f0f099ede 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -947,19 +947,16 @@ function initializeCollator(collator, locales, options) {
*
* @constructor
*/
-%AddNamedProperty(Intl, 'Collator', function() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+function Collator() {
+ var locales = %_Arguments(0);
+ var options = %_Arguments(1);
- if (!this || this === Intl) {
- // Constructor is called as a function.
- return new Intl.Collator(locales, options);
- }
+ if (IS_UNDEFINED(new.target)) return new Collator(locales, options);
- return initializeCollator(TO_OBJECT(this), locales, options);
- },
- DONT_ENUM
-);
+ return initializeCollator(this, locales, options);
+}
+
+%AddNamedProperty(Intl, 'Collator', Collator, DONT_ENUM);
/**
@@ -1189,19 +1186,15 @@ function initializeNumberFormat(numberFormat, locales, options) {
*
* @constructor
*/
-%AddNamedProperty(Intl, 'NumberFormat', function() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+function NumberFormat() {
+ var locales = %_Arguments(0);
+ var options = %_Arguments(1);
- if (!this || this === Intl) {
- // Constructor is called as a function.
- return new Intl.NumberFormat(locales, options);
- }
+ if (IS_UNDEFINED(new.target)) return new NumberFormat(locales, options);
- return initializeNumberFormat(TO_OBJECT(this), locales, options);
- },
- DONT_ENUM
-);
+ return initializeNumberFormat(this, locales, options);
+}
+%AddNamedProperty(Intl, 'NumberFormat', NumberFormat, DONT_ENUM);
/**
@@ -1591,19 +1584,15 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
*
* @constructor
*/
-%AddNamedProperty(Intl, 'DateTimeFormat', function() {
- var locales = %_Arguments(0);
- var options = %_Arguments(1);
+function DateTimeFormat() {
+ var locales = %_Arguments(0);
+ var options = %_Arguments(1);
- if (!this || this === Intl) {
- // Constructor is called as a function.
- return new Intl.DateTimeFormat(locales, options);
- }
+ if (IS_UNDEFINED(new.target)) return new DateTimeFormat(locales, options);
- return initializeDateTimeFormat(TO_OBJECT(this), locales, options);
- },
- DONT_ENUM
-);
+ return initializeDateTimeFormat(this, locales, options);
+}
+%AddNamedProperty(Intl, 'DateTimeFormat', DateTimeFormat, 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