mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add basic Array.from polyfill for IE11
This commit is contained in:
parent
57f0fbbb98
commit
5dc1cc54d5
@ -18,17 +18,22 @@
|
|||||||
// changes to support iterables.
|
// changes to support iterables.
|
||||||
throw new Error("Missing Array.from base polyfill");
|
throw new Error("Missing Array.from base polyfill");
|
||||||
}
|
}
|
||||||
Array._from = Array.from;
|
|
||||||
Array.from = function() {
|
Array.from = function() {
|
||||||
|
if (arguments.length > 1) {
|
||||||
|
throw new Error("Node-RED's IE11 Array.from polyfill doesn't support multiple arguments");
|
||||||
|
}
|
||||||
var arrayLike = arguments[0]
|
var arrayLike = arguments[0]
|
||||||
if (arrayLike.forEach) {
|
if (arrayLike.forEach) {
|
||||||
var result = [];
|
var result = [];
|
||||||
arrayLike.forEach(function(i) {
|
arrayLike.forEach(function(i) {
|
||||||
result.push(i);
|
result.push(i);
|
||||||
})
|
})
|
||||||
return result;
|
} else {
|
||||||
|
for (var i=0;i<arrayLike.length;i++) {
|
||||||
|
result.push(arrayList[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Array._from.apply(null,arguments);
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user