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

Commit 422bf22

Browse files
committed
fix: should not wrap on ie10
1 parent b34a921 commit 422bf22

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/code/polyfill.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ function _setPrototypeOf(subClass, superClass) {
4848
return subClass;
4949
}
5050

51+
function _isNativeFunction(fn) {
52+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
53+
}
54+
5155
function _wrapNativeSuper(Class) {
56+
if (!_isNativeFunction(Class)) {
57+
return Class;
58+
}
5259
function Wrapper() {
5360
const prototypeConstructor = _getPrototypeOf(this).constructor;
5461
const args = [null];
@@ -105,7 +112,7 @@ export default function polyfill(globalSpace) {
105112
const jsonClone = function(o) {
106113
return JSON.parse(JSON.stringify(o));
107114
};
108-
const _DateTimeFormat = gIntl.DateTimeFormat;
115+
const _DateTimeFormat = _wrapNativeSuper(gIntl.DateTimeFormat);
109116

110117
gIntl._DateTimeFormat = _DateTimeFormat;
111118

@@ -125,7 +132,7 @@ export default function polyfill(globalSpace) {
125132
if (options === undefined) {
126133
// options is not provided. this means
127134
// we don't need to format arbitrary timezone
128-
_this = _getPrototypeOf(DateTimeFormatPolyfill).call(this, locale, options);
135+
_this = _DateTimeFormat.call(this, locale, options);
129136

130137
if (_this.formatToParts) {
131138
_this._nativeObject = new _DateTimeFormat(locale, options);
@@ -136,7 +143,7 @@ export default function polyfill(globalSpace) {
136143

137144
if (checkTimeZoneSupport(timeZone)) {
138145
// native method has support for timezone. no polyfill logic needed.
139-
_this = _getPrototypeOf(DateTimeFormatPolyfill).call(this, locale, options);
146+
_this = _DateTimeFormat.call(this, locale, options);
140147

141148
if (_this.formatToParts) {
142149
_this._nativeObject = new _DateTimeFormat(locale, options);
@@ -155,7 +162,7 @@ export default function polyfill(globalSpace) {
155162
// Do a timeshift to UTC to avoid explosion due to unsupprted timezone.
156163
const tsOption = jsonClone(options);
157164
tsOption.timeZone = 'UTC';
158-
_this = _getPrototypeOf(DateTimeFormatPolyfill).call(this, locale, tsOption);
165+
_this = _DateTimeFormat.call(this, locale, tsOption);
159166

160167
const _resolvedOptions = _get(
161168
_getPrototypeOf(DateTimeFormatPolyfill.prototype),
@@ -183,7 +190,7 @@ export default function polyfill(globalSpace) {
183190

184191
return _this;
185192
}
186-
_inherits(DateTimeFormatPolyfill, _wrapNativeSuper(_DateTimeFormat));
193+
_inherits(DateTimeFormatPolyfill, _DateTimeFormat);
187194

188195
Object.defineProperty(DateTimeFormatPolyfill.prototype, 'format', {
189196
configurable: true,

0 commit comments

Comments
 (0)