node-red/packages/node_modules/@node-red/editor-client/src/js/polyfills.js

42 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-04-03 17:56:46 +02:00
(function() {
var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
if (isIE11) {
// IE11 DOMTokenList.toggle does not support the two-argument variety
window.DOMTokenList.prototype.toggle = function(cl,bo) {
if (arguments.length === 1) {
bo = !this.contains(cl);
}
this[!!bo?"add":"remove"](cl);
}
2020-04-03 17:56:46 +02:00
// IE11 does not provide classList on SVGElements
if (! ("classList" in SVGElement.prototype)) {
Object.defineProperty(SVGElement.prototype, 'classList', Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'classList'));
}
// IE11 does not provide children on SVGElements
if (! ("children" in SVGElement.prototype)) {
Object.defineProperty(SVGElement.prototype, 'children', Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'children'));
}
Array.from = function() {
2020-05-21 11:26:24 +02:00
if (arguments.length > 1) {
throw new Error("Node-RED's IE11 Array.from polyfill doesn't support multiple arguments");
}
2020-04-03 17:56:46 +02:00
var arrayLike = arguments[0]
2020-05-22 16:31:38 +02:00
var result = [];
2020-04-03 17:56:46 +02:00
if (arrayLike.forEach) {
arrayLike.forEach(function(i) {
result.push(i);
})
2020-05-21 11:26:24 +02:00
} else {
for (var i=0;i<arrayLike.length;i++) {
result.push(arrayList[i]);
}
2020-04-03 17:56:46 +02:00
}
2020-05-21 11:26:24 +02:00
return result;
2020-04-03 17:56:46 +02:00
}
}
})();