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

Side by Side 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 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // ECMAScript 402 API implementation. 5 // ECMAScript 402 API implementation.
6 6
7 /** 7 /**
8 * Intl object is a single object that has some named properties, 8 * Intl object is a single object that has some named properties,
9 * all of which are constructors. 9 * all of which are constructors.
10 */ 10 */
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 return collator; 940 return collator;
941 } 941 }
942 942
943 943
944 /** 944 /**
945 * Constructs Intl.Collator object given optional locales and options 945 * Constructs Intl.Collator object given optional locales and options
946 * parameters. 946 * parameters.
947 * 947 *
948 * @constructor 948 * @constructor
949 */ 949 */
950 function Collator() { 950 %AddNamedProperty(Intl, 'Collator', function() {
951 var locales = %_Arguments(0); 951 var locales = %_Arguments(0);
952 var options = %_Arguments(1); 952 var options = %_Arguments(1);
953 953
954 if (IS_UNDEFINED(new.target)) return new Collator(locales, options); 954 if (!this || this === Intl) {
955 // Constructor is called as a function.
956 return new Intl.Collator(locales, options);
957 }
955 958
956 return initializeCollator(this, locales, options); 959 return initializeCollator(TO_OBJECT(this), locales, options);
957 } 960 },
958 961 DONT_ENUM
959 %AddNamedProperty(Intl, 'Collator', Collator, DONT_ENUM); 962 );
960 963
961 964
962 /** 965 /**
963 * Collator resolvedOptions method. 966 * Collator resolvedOptions method.
964 */ 967 */
965 %AddNamedProperty(Intl.Collator.prototype, 'resolvedOptions', function() { 968 %AddNamedProperty(Intl.Collator.prototype, 'resolvedOptions', function() {
966 if (%_IsConstructCall()) { 969 if (%_IsConstructCall()) {
967 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); 970 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
968 } 971 }
969 972
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 return numberFormat; 1182 return numberFormat;
1180 } 1183 }
1181 1184
1182 1185
1183 /** 1186 /**
1184 * Constructs Intl.NumberFormat object given optional locales and options 1187 * Constructs Intl.NumberFormat object given optional locales and options
1185 * parameters. 1188 * parameters.
1186 * 1189 *
1187 * @constructor 1190 * @constructor
1188 */ 1191 */
1189 function NumberFormat() { 1192 %AddNamedProperty(Intl, 'NumberFormat', function() {
1190 var locales = %_Arguments(0); 1193 var locales = %_Arguments(0);
1191 var options = %_Arguments(1); 1194 var options = %_Arguments(1);
1192 1195
1193 if (IS_UNDEFINED(new.target)) return new NumberFormat(locales, options); 1196 if (!this || this === Intl) {
1197 // Constructor is called as a function.
1198 return new Intl.NumberFormat(locales, options);
1199 }
1194 1200
1195 return initializeNumberFormat(this, locales, options); 1201 return initializeNumberFormat(TO_OBJECT(this), locales, options);
1196 } 1202 },
1197 %AddNamedProperty(Intl, 'NumberFormat', NumberFormat, DONT_ENUM); 1203 DONT_ENUM
1204 );
1198 1205
1199 1206
1200 /** 1207 /**
1201 * NumberFormat resolvedOptions method. 1208 * NumberFormat resolvedOptions method.
1202 */ 1209 */
1203 %AddNamedProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() { 1210 %AddNamedProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
1204 if (%_IsConstructCall()) { 1211 if (%_IsConstructCall()) {
1205 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); 1212 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
1206 } 1213 }
1207 1214
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 return dateFormat; 1584 return dateFormat;
1578 } 1585 }
1579 1586
1580 1587
1581 /** 1588 /**
1582 * Constructs Intl.DateTimeFormat object given optional locales and options 1589 * Constructs Intl.DateTimeFormat object given optional locales and options
1583 * parameters. 1590 * parameters.
1584 * 1591 *
1585 * @constructor 1592 * @constructor
1586 */ 1593 */
1587 function DateTimeFormat() { 1594 %AddNamedProperty(Intl, 'DateTimeFormat', function() {
1588 var locales = %_Arguments(0); 1595 var locales = %_Arguments(0);
1589 var options = %_Arguments(1); 1596 var options = %_Arguments(1);
1590 1597
1591 if (IS_UNDEFINED(new.target)) return new DateTimeFormat(locales, options); 1598 if (!this || this === Intl) {
1599 // Constructor is called as a function.
1600 return new Intl.DateTimeFormat(locales, options);
1601 }
1592 1602
1593 return initializeDateTimeFormat(this, locales, options); 1603 return initializeDateTimeFormat(TO_OBJECT(this), locales, options);
1594 } 1604 },
1595 %AddNamedProperty(Intl, 'DateTimeFormat', DateTimeFormat, DONT_ENUM); 1605 DONT_ENUM
1606 );
1596 1607
1597 1608
1598 /** 1609 /**
1599 * DateTimeFormat resolvedOptions method. 1610 * DateTimeFormat resolvedOptions method.
1600 */ 1611 */
1601 %AddNamedProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { 1612 %AddNamedProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
1602 if (%_IsConstructCall()) { 1613 if (%_IsConstructCall()) {
1603 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); 1614 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
1604 } 1615 }
1605 1616
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 } 2113 }
2103 2114
2104 var locales = %_Arguments(0); 2115 var locales = %_Arguments(0);
2105 var options = %_Arguments(1); 2116 var options = %_Arguments(1);
2106 return toLocaleDateTime( 2117 return toLocaleDateTime(
2107 this, locales, options, 'time', 'time', 'dateformattime'); 2118 this, locales, options, 'time', 'time', 'dateformattime');
2108 } 2119 }
2109 ); 2120 );
2110 2121
2111 }) 2122 })
OLDNEW
« 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