Skip to content

Commit d43b3a8

Browse files
committed
add polyfill for Object.assign (IE 11 issue)
1 parent 44b1290 commit d43b3a8

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './polyfill'
12
import SketchField from './SketchField'
23
import Tools from './tools'
34

src/polyfill.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Object.assign() polyfill for IE11
3+
* @see <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign>
4+
*/
5+
6+
if (typeof Object.assign != "function") {
7+
Object.defineProperty(Object, "assign", {
8+
value: function assign(target, varArgs) {
9+
"use strict";
10+
if (target == null) {
11+
throw new TypeError("Cannot convert undefined or null to object");
12+
}
13+
var to = Object(target);
14+
for (var index = 1; index < arguments.length; index++) {
15+
var nextSource = arguments[index];
16+
if (nextSource != null) {
17+
for (var nextKey in nextSource) {
18+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
19+
to[nextKey] = nextSource[nextKey];
20+
}
21+
}
22+
}
23+
}
24+
return to;
25+
},
26+
writable: true,
27+
configurable: true
28+
});
29+
}

0 commit comments

Comments
 (0)