1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Use RED.nodes.filterLinks in pref to RED.nodes.eachLink

This commit is contained in:
Nick O'Leary 2015-03-15 23:41:16 +00:00
parent cf8fe16b09
commit 9c104faff3
3 changed files with 5 additions and 9 deletions

View File

@ -813,6 +813,9 @@ RED.nodes = (function() {
continue; continue;
} }
} }
if (filter.sourcePort && link.sourcePort !== filter.sourcePort) {
continue;
}
result.push(link); result.push(link);
} }
return result; return result;

View File

@ -114,11 +114,7 @@ RED.editor = (function() {
} }
} }
if (node.inputs === 0) { if (node.inputs === 0) {
RED.nodes.eachLink(function(l) { removedLinks.concat(RED.nodes.filterLinks({target:node}));
if (l.target === node) {
removedLinks.push(l);
}
});
} }
for (var l=0;l<removedLinks.length;l++) { for (var l=0;l<removedLinks.length;l++) {
RED.nodes.removeLink(removedLinks[l]); RED.nodes.removeLink(removedLinks[l]);

View File

@ -929,10 +929,7 @@ RED.view = (function() {
dst = mousedown_node; dst = mousedown_node;
src_port = portIndex; src_port = portIndex;
} }
var existingLink = false; var existingLink = RED.nodes.filterLinks({source:src,target:dst,sourcePort: src_port}).length !== 0;
RED.nodes.eachLink(function(d) {
existingLink = existingLink || (d.source === src && d.target === dst && d.sourcePort == src_port);
});
if (!existingLink) { if (!existingLink) {
var link = {source: src, sourcePort:src_port, target: dst}; var link = {source: src, sourcePort:src_port, target: dst};
RED.nodes.addLink(link); RED.nodes.addLink(link);