Skip to content

Commit

Permalink
Revert of [Intl] create new instances when new.target is undefined (p…
Browse files Browse the repository at this point in the history
…atchset v8#2 id:20001 of https://codereview.chromium.org/1440593003/ )

Reason for revert:
This breaks backwards compatibility by disallowing call. Web application authors have noticed the breakage. tc39/ecma402#57

Original issue's description:
> [Intl] create new instances when new.target is undefined
>
> BUG=v8:4360
> LOG=N
> R=littledan@chromium.org
>
> Committed: https://crrev.com/fa9c39eeadd8e692af03b024fe2fdcf94ad0da6b
> Cr-Commit-Position: refs/heads/master@{#31971}

TBR=caitpotter88@gmail.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:4360

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

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


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


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


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

Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 70177a8

Please sign in to comment.