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

57 lines
2.0 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
}
2020-08-04 21:59:32 +02:00
if (new Set([0]).size === 0) {
// IE does not support passing an iterable to Set constructor
var _Set = Set;
2020-08-05 15:58:43 +02:00
/*global Set:true */
2020-08-04 21:59:32 +02:00
Set = function Set(iterable) {
var set = new _Set();
if (iterable) {
iterable.forEach(set.add, set);
}
return set;
};
Set.prototype = _Set.prototype;
Set.prototype.constructor = Set;
}
2020-04-03 17:56:46 +02:00
}
})();