mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Improve the filter to handle all cases + comments
Co-authored-by: Nick O'Leary <nick.oleary@gmail.com>
This commit is contained in:
parent
2c4dc3334d
commit
912a30b28d
@ -2406,15 +2406,25 @@ RED.nodes = (function() {
|
|||||||
} else {
|
} else {
|
||||||
delete n.g
|
delete n.g
|
||||||
}
|
}
|
||||||
// If importing a subflow, ensure an outbound-link doesn't get added
|
// If importing a link node, ensure both ends of each link are either:
|
||||||
|
// - not in a subflow
|
||||||
|
// - both in the same subflow
|
||||||
if (/^link /.test(n.type) && n.links) {
|
if (/^link /.test(n.type) && n.links) {
|
||||||
const isSubflow = !!getSubflow(n.z);
|
n.links = n.links.filter(function(id) {
|
||||||
if (isSubflow) {
|
const otherNode = node_map[id] || RED.nodes.node(id);
|
||||||
n.links = n.links.filter(function(id) {
|
if (!otherNode) {
|
||||||
const otherNode = node_map[id] || RED.nodes.node(id);
|
// Cannot find other end - remove the link
|
||||||
return (otherNode && otherNode.z === n.z);
|
return false
|
||||||
});
|
}
|
||||||
}
|
if (otherNode.z === n.z) {
|
||||||
|
// Both ends in the same flow/subflow
|
||||||
|
return true
|
||||||
|
} else if (!!getSubflow(n.z) || !!getSubflow(otherNode.z)) {
|
||||||
|
// One end is in a subflow - remove the link
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
for (var d3 in n._def.defaults) {
|
for (var d3 in n._def.defaults) {
|
||||||
if (n._def.defaults.hasOwnProperty(d3)) {
|
if (n._def.defaults.hasOwnProperty(d3)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user