Skip to content

Commit eea02da

Browse files
panthonykt3k
authored andcommitted
add polyfill for Object.assign as it is not supported by IE11 (#2710)
1 parent 391897d commit eea02da

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/polyfill.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,4 +1612,36 @@ if (!String.prototype.padEnd) {
16121612
};
16131613
}
16141614

1615+
// Object.assign polyfill for IE11
1616+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
1617+
if (typeof Object.assign !== 'function') {
1618+
// Must be writable: true, enumerable: false, configurable: true
1619+
Object.defineProperty(Object, "assign", {
1620+
value: function assign(target, varArgs) { // .length of function is 2
1621+
'use strict';
1622+
if (target === null || target === undefined) {
1623+
throw new TypeError('Cannot convert undefined or null to object');
1624+
}
1625+
1626+
var to = Object(target);
1627+
1628+
for (var index = 1; index < arguments.length; index++) {
1629+
var nextSource = arguments[index];
1630+
1631+
if (nextSource !== null && nextSource !== undefined) {
1632+
for (var nextKey in nextSource) {
1633+
// Avoid bugs when hasOwnProperty is shadowed
1634+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
1635+
to[nextKey] = nextSource[nextKey];
1636+
}
1637+
}
1638+
}
1639+
}
1640+
return to;
1641+
},
1642+
writable: true,
1643+
configurable: true
1644+
});
1645+
}
1646+
16151647
/* jshint ignore:end */

0 commit comments

Comments
 (0)