Skip to content

Commit

Permalink
[Intl] create new instances when new.target is undefined
Browse files Browse the repository at this point in the history
BUG=v8:4360
LOG=N
R=littledan@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#31971}
  • Loading branch information
caitp authored and Commit bot committed Nov 12, 2015
1 parent ccae6b5 commit fa9c39e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 39 deletions.
55 changes: 22 additions & 33 deletions src/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);


/**
Expand Down Expand Up @@ -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);


/**
Expand Down Expand Up @@ -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);


/**
Expand Down
6 changes: 0 additions & 6 deletions test/test262/test262.status
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,6 @@
# 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],

Expand Down Expand Up @@ -522,7 +517,6 @@
'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],
Expand Down

0 comments on commit fa9c39e

Please sign in to comment.