-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpolyfill.js
More file actions
36 lines (32 loc) · 1.02 KB
/
polyfill.js
File metadata and controls
36 lines (32 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
if ("NodeList" in window && !NodeList.prototype.forEach) {
console.info("polyfill for IE11");
NodeList.prototype.forEach = function(callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
if (!Object.prototype.forEach) {
Object.defineProperty(Object.prototype, "forEach", {
value: function(callback, thisArg) {
if (this == null) {
throw new TypeError("Not an object");
}
thisArg = thisArg || window;
for (var key in this) {
if (this.hasOwnProperty(key)) {
callback.call(thisArg, this[key], key, this);
}
}
}
});
}