mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
c061487a16
This is a slightly scary set of changes to be making. It overhauls how the view is rendered. Rather than use d3 for every single part of generating the view, we new use native DOM functions as much as possible. d3 is still used for the basic heavy lifting of working out what nodes/links etc need to be added/removed from the view. But once it comes to rendering them, d3 is side-lined as much as possible. There's room for further improvement. This change focusses on Nodes and Links. It has not touched groups, subflow-ports and link-nodes.
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
(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);
|
|
}
|
|
|
|
// 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() {
|
|
if (arguments.length > 1) {
|
|
throw new Error("Node-RED's IE11 Array.from polyfill doesn't support multiple arguments");
|
|
}
|
|
var arrayLike = arguments[0]
|
|
var result = [];
|
|
if (arrayLike.forEach) {
|
|
arrayLike.forEach(function(i) {
|
|
result.push(i);
|
|
})
|
|
} else {
|
|
for (var i=0;i<arrayLike.length;i++) {
|
|
result.push(arrayList[i]);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
})();
|