Skip to content
This repository was archived by the owner on Oct 21, 2023. It is now read-only.

Commit 8ee4b5c

Browse files
polyfill Object.assign for IE
it's actually pretty useful here, willing to bloat the library a little for #7
1 parent beea2d5 commit 8ee4b5c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/core.js

+30
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,33 @@ var dc_datatables = {
33
version: '<%= conf.pkg.version %>'
44
};
55

6+
// Object.assign polyfill for IE
7+
if (typeof Object.assign != 'function') {
8+
// Must be writable: true, enumerable: false, configurable: true
9+
Object.defineProperty(Object, "assign", {
10+
value: function assign(target, varArgs) { // .length of function is 2
11+
'use strict';
12+
if (target == null) { // TypeError if undefined or null
13+
throw new TypeError('Cannot convert undefined or null to object');
14+
}
15+
16+
var to = Object(target);
17+
18+
for (var index = 1; index < arguments.length; index++) {
19+
var nextSource = arguments[index];
20+
21+
if (nextSource != null) { // Skip over if undefined or null
22+
for (var nextKey in nextSource) {
23+
// Avoid bugs when hasOwnProperty is shadowed
24+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
25+
to[nextKey] = nextSource[nextKey];
26+
}
27+
}
28+
}
29+
}
30+
return to;
31+
},
32+
writable: true,
33+
configurable: true
34+
});
35+
}

0 commit comments

Comments
 (0)