diff --git a/src/js/i18n.js b/src/js/i18n.js index 1920bbb735a8..f2b9dd4445e6 100644 --- a/src/js/i18n.js +++ b/src/js/i18n.js @@ -947,16 +947,19 @@ function initializeCollator(collator, locales, options) { * * @constructor */ -function Collator() { - var locales = %_Arguments(0); - var options = %_Arguments(1); - - if (IS_UNDEFINED(new.target)) return new Collator(locales, options); +%AddNamedProperty(Intl, 'Collator', function() { + var locales = %_Arguments(0); + var options = %_Arguments(1); - return initializeCollator(this, locales, options); -} + if (!this || this === Intl) { + // Constructor is called as a function. + return new Intl.Collator(locales, options); + } -%AddNamedProperty(Intl, 'Collator', Collator, DONT_ENUM); + return initializeCollator(TO_OBJECT(this), locales, options); + }, + DONT_ENUM +); /** @@ -1186,15 +1189,19 @@ function initializeNumberFormat(numberFormat, locales, options) { * * @constructor */ -function NumberFormat() { - var locales = %_Arguments(0); - var options = %_Arguments(1); +%AddNamedProperty(Intl, 'NumberFormat', function() { + var locales = %_Arguments(0); + var options = %_Arguments(1); - if (IS_UNDEFINED(new.target)) return new NumberFormat(locales, options); + if (!this || this === Intl) { + // Constructor is called as a function. + return new Intl.NumberFormat(locales, options); + } - return initializeNumberFormat(this, locales, options); -} -%AddNamedProperty(Intl, 'NumberFormat', NumberFormat, DONT_ENUM); + return initializeNumberFormat(TO_OBJECT(this), locales, options); + }, + DONT_ENUM +); /** @@ -1584,15 +1591,19 @@ function initializeDateTimeFormat(dateFormat, locales, options) { * * @constructor */ -function DateTimeFormat() { - var locales = %_Arguments(0); - var options = %_Arguments(1); +%AddNamedProperty(Intl, 'DateTimeFormat', function() { + var locales = %_Arguments(0); + var options = %_Arguments(1); - if (IS_UNDEFINED(new.target)) return new DateTimeFormat(locales, options); + if (!this || this === Intl) { + // Constructor is called as a function. + return new Intl.DateTimeFormat(locales, options); + } - return initializeDateTimeFormat(this, locales, options); -} -%AddNamedProperty(Intl, 'DateTimeFormat', DateTimeFormat, DONT_ENUM); + return initializeDateTimeFormat(TO_OBJECT(this), locales, options); + }, + DONT_ENUM +); /** diff --git a/test/test262/test262.status b/test/test262/test262.status index 13e39dea67c8..1412b872d727 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -358,6 +358,11 @@ # https://code.google.com/p/v8/issues/detail?id=4346 'built-ins/RegExp/prototype/flags/u': [FAIL], + # https://code.google.com/p/v8/issues/detail?id=4360 + 'intl402/Collator/10.1.1_1': [FAIL], + 'intl402/DateTimeFormat/12.1.1_1': [FAIL], + 'intl402/NumberFormat/11.1.1_1': [FAIL], + # https://code.google.com/p/v8/issues/detail?id=4361 'intl402/Collator/10.1.1_a': [FAIL], @@ -403,6 +408,7 @@ 'intl402/Date/prototype/13.3.0_7': [FAIL], 'intl402/DateTimeFormat/12.1.1': [FAIL], 'intl402/DateTimeFormat/12.1.1_a': [FAIL], + 'intl402/DateTimeFormat/12.1.1_1': [FAIL], 'intl402/DateTimeFormat/12.1.2': [PASS, FAIL], 'intl402/DateTimeFormat/12.1.2.1_4': [FAIL], 'intl402/DateTimeFormat/12.2.3_b': [FAIL],