Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 5cc5479

Browse files
authored
Merge pull request #26 from markandey/fixformattoparts
Use native object for formatToParts
2 parents 4a9b6fb + a9b0126 commit 5cc5479

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

karma.conf.saucelabs.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ module.exports = function(config) {
2020
sl_edge: {
2121
base: 'SauceLabs',
2222
browserName: 'microsoftedge'
23+
},
24+
sl_firefox: {
25+
base: 'SauceLabs',
26+
browserName: 'firefox',
27+
version: '64'
2328
}
2429
};
2530

@@ -45,6 +50,6 @@ module.exports = function(config) {
4550
browserNoActivityTimeout: 100000,
4651
port: 9999,
4752
singleRun: true,
48-
browsers: ['sl_ie_10', 'sl_edge', 'sl_ie_11', 'sl_safari']
53+
browsers: ['sl_ie_10', 'sl_edge', 'sl_ie_11', 'sl_safari', 'sl_firefox']
4954
});
5055
};

src/code/polyfill.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,21 @@ export default function polyfill(globalSpace) {
9090
// we don't need to format arbitrary timezone
9191
_DateTimeFormat.call(this, locale, options);
9292

93+
if (this.formatToParts) {
94+
this._nativeObject = new _DateTimeFormat(locale, options);
95+
}
96+
9397
return;
9498
}
9599

96100
if (checkTimeZoneSupport(timeZone)) {
97101
// native method has support for timezone. no polyfill logic needed.
98102
_DateTimeFormat.call(this, locale, options);
99103

104+
if (this.formatToParts) {
105+
this._nativeObject = new _DateTimeFormat(locale, options);
106+
}
107+
100108
return;
101109
}
102110

@@ -229,8 +237,8 @@ export default function polyfill(globalSpace) {
229237
this
230238
);
231239

232-
if (!this._dateTimeFormatPolyfill) {
233-
return _formatToParts.call(this, date);
240+
if (!this._dateTimeFormatPolyfill && this._nativeObject) {
241+
return this._nativeObject.formatToParts(date);
234242
}
235243

236244
if (date === null || date === undefined) {

0 commit comments

Comments
 (0)