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

Unified Diff: src/js/i18n.js

Issue 2587713002: [intl] Remove new.target check in Intl functions and method (Closed)
Patch Set: rebase Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/intl/not-constructors.js » ('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 34a5e98d6684c438e5348ad214cc6750e5490ef5..803f55054de5c6673165f6965ba06f7f352496a7 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -912,10 +912,6 @@ var resolvedAccessor = {
// ECMA 402 section 8.2.1
InstallFunction(Intl, 'getCanonicalLocales', function(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
return makeArray(canonicalizeLocaleList(locales));
}
);
@@ -1051,10 +1047,6 @@ InstallConstructor(Intl, 'Collator', function() {
* Collator resolvedOptions method.
*/
InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (!%IsInitializedIntlObjectOfType(this, 'collator')) {
throw %make_type_error(kResolvedOptionsCalledOnNonObject, "Collator");
}
@@ -1083,10 +1075,6 @@ InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() {
* Options are optional parameter.
*/
InstallFunction(Intl.Collator, 'supportedLocalesOf', function(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
return supportedLocalesOf('collator', locales, arguments[1]);
}
);
@@ -1292,10 +1280,6 @@ InstallConstructor(Intl, 'NumberFormat', function() {
* NumberFormat resolvedOptions method.
*/
InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (!%IsInitializedIntlObjectOfType(this, 'numberformat')) {
throw %make_type_error(kResolvedOptionsCalledOnNonObject, "NumberFormat");
}
@@ -1342,10 +1326,6 @@ InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
* Options are optional parameter.
*/
InstallFunction(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
return supportedLocalesOf('numberformat', locales, arguments[1]);
}
);
@@ -1676,10 +1656,6 @@ InstallConstructor(Intl, 'DateTimeFormat', function() {
* DateTimeFormat resolvedOptions method.
*/
InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (!%IsInitializedIntlObjectOfType(this, 'dateformat')) {
throw %make_type_error(kResolvedOptionsCalledOnNonObject, "DateTimeFormat");
}
@@ -1736,10 +1712,6 @@ InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
* Options are optional parameter.
*/
InstallFunction(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
return supportedLocalesOf('dateformat', locales, arguments[1]);
}
);
@@ -1765,9 +1737,6 @@ function formatDate(formatter, dateValue) {
}
function FormatDateToParts(dateValue) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
CHECK_OBJECT_COERCIBLE(this, "Intl.DateTimeFormat.prototype.formatToParts");
if (!IS_OBJECT(this)) {
throw %make_type_error(kCalledOnNonObject, this);
@@ -2075,10 +2044,6 @@ function LocaleConvertCase(s, locales, isToUpper) {
* Overrides the built-in method.
*/
OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (IS_NULL_OR_UNDEFINED(this)) {
throw %make_type_error(kMethodInvokedOnNullOrUndefined);
}
@@ -2100,10 +2065,6 @@ OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
*/
OverrideFunction(GlobalString.prototype, 'normalize', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
var s = TO_STRING(this);
@@ -2164,10 +2125,6 @@ utils.Export(function(to) {
* If locale or options are omitted, defaults are used.
*/
OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') {
throw %make_type_error(kMethodInvokedOnWrongType, "Number");
}
@@ -2206,10 +2163,6 @@ function toLocaleDateTime(date, locales, options, required, defaults, service) {
* present in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
var locales = arguments[0];
var options = arguments[1];
return toLocaleDateTime(
@@ -2224,10 +2177,6 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
* in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
var locales = arguments[0];
var options = arguments[1];
return toLocaleDateTime(
@@ -2242,10 +2191,6 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
* in the output.
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
- if (!IS_UNDEFINED(new.target)) {
- throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
- }
-
var locales = arguments[0];
var options = arguments[1];
return toLocaleDateTime(
« no previous file with comments | « no previous file | test/intl/not-constructors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698