mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 07:25:15 +02:00
Intl sub-classing is now restricted to class syntax.
This commit is contained in:
parent
888524ff1d
commit
438b87b5b6
@ -15,14 +15,13 @@ var a = ["A", "C", "E", "B", "D", "F"];
|
|||||||
var referenceCollator = new Intl.Collator(locales);
|
var referenceCollator = new Intl.Collator(locales);
|
||||||
var referenceSorted = a.slice().sort(referenceCollator.compare);
|
var referenceSorted = a.slice().sort(referenceCollator.compare);
|
||||||
|
|
||||||
function MyCollator(locales, options) {
|
class MyCollator extends Intl.Collator {
|
||||||
Intl.Collator.call(this, locales, options);
|
constructor(locales, options) {
|
||||||
|
super(locales, options);
|
||||||
// could initialize MyCollator properties
|
// could initialize MyCollator properties
|
||||||
}
|
}
|
||||||
|
|
||||||
MyCollator.prototype = Object.create(Intl.Collator.prototype);
|
|
||||||
MyCollator.prototype.constructor = MyCollator;
|
|
||||||
// could add methods to MyCollator.prototype
|
// could add methods to MyCollator.prototype
|
||||||
|
}
|
||||||
|
|
||||||
var collator = new MyCollator(locales);
|
var collator = new MyCollator(locales);
|
||||||
a.sort(collator.compare);
|
a.sort(collator.compare);
|
||||||
|
@ -15,14 +15,13 @@ var a = [0, 1, -1, -123456.789, -Infinity, NaN];
|
|||||||
var referenceNumberFormat = new Intl.NumberFormat(locales);
|
var referenceNumberFormat = new Intl.NumberFormat(locales);
|
||||||
var referenceFormatted = a.map(referenceNumberFormat.format);
|
var referenceFormatted = a.map(referenceNumberFormat.format);
|
||||||
|
|
||||||
function MyNumberFormat(locales, options) {
|
class MyNumberFormat extends Intl.NumberFormat {
|
||||||
Intl.NumberFormat.call(this, locales, options);
|
constructor(locales, options) {
|
||||||
|
super(locales, options);
|
||||||
// could initialize MyNumberFormat properties
|
// could initialize MyNumberFormat properties
|
||||||
}
|
}
|
||||||
|
|
||||||
MyNumberFormat.prototype = Object.create(Intl.NumberFormat.prototype);
|
|
||||||
MyNumberFormat.prototype.constructor = MyNumberFormat;
|
|
||||||
// could add methods to MyNumberFormat.prototype
|
// could add methods to MyNumberFormat.prototype
|
||||||
|
}
|
||||||
|
|
||||||
var format = new MyNumberFormat(locales);
|
var format = new MyNumberFormat(locales);
|
||||||
var actual = a.map(format.format);
|
var actual = a.map(format.format);
|
||||||
|
@ -15,14 +15,13 @@ var a = [new Date(0), Date.now(), new Date(Date.parse("1989-11-09T17:57:00Z"))];
|
|||||||
var referenceDateTimeFormat = new Intl.DateTimeFormat(locales);
|
var referenceDateTimeFormat = new Intl.DateTimeFormat(locales);
|
||||||
var referenceFormatted = a.map(referenceDateTimeFormat.format);
|
var referenceFormatted = a.map(referenceDateTimeFormat.format);
|
||||||
|
|
||||||
function MyDateTimeFormat(locales, options) {
|
class MyDateTimeFormat extends Intl.DateTimeFormat {
|
||||||
Intl.DateTimeFormat.call(this, locales, options);
|
constructor(locales, options) {
|
||||||
|
super(locales, options);
|
||||||
// could initialize MyDateTimeFormat properties
|
// could initialize MyDateTimeFormat properties
|
||||||
}
|
}
|
||||||
|
|
||||||
MyDateTimeFormat.prototype = Object.create(Intl.DateTimeFormat.prototype);
|
|
||||||
MyDateTimeFormat.prototype.constructor = MyDateTimeFormat;
|
|
||||||
// could add methods to MyDateTimeFormat.prototype
|
// could add methods to MyDateTimeFormat.prototype
|
||||||
|
}
|
||||||
|
|
||||||
var format = new MyDateTimeFormat(locales);
|
var format = new MyDateTimeFormat(locales);
|
||||||
var actual = a.map(format.format);
|
var actual = a.map(format.format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user