mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Fix importing a node with an invalid number of outputs.
This commit is contained in:
parent
39d8386e43
commit
e5db6661c3
@ -1937,31 +1937,29 @@ RED.nodes = (function() {
|
||||
newNode._config.x = node.x;
|
||||
newNode._config.y = node.y;
|
||||
|
||||
if (node.hasOwnProperty("inputs")) {
|
||||
if (node.hasOwnProperty("inputs") && def.defaults.hasOwnProperty("inputs")) {
|
||||
newNode._config.inputs = JSON.stringify(node.inputs);
|
||||
newNode.inputs = node.inputs;
|
||||
newNode.inputs = parseInt(node.inputs, 10);
|
||||
} else {
|
||||
newNode.inputs = def.inputs;
|
||||
}
|
||||
|
||||
if (node.hasOwnProperty("outputs")) {
|
||||
if (node.hasOwnProperty("outputs") && def.defaults.hasOwnProperty("outputs")) {
|
||||
newNode._config.outputs = JSON.stringify(node.outputs);
|
||||
newNode.outputs = node.outputs;
|
||||
newNode.outputs = parseInt(node.outputs, 10);
|
||||
} else {
|
||||
newNode.outputs = def.outputs;
|
||||
}
|
||||
|
||||
if (newNode.wires.length > newNode.outputs) {
|
||||
if (!def.defaults.hasOwnProperty("outputs") || !isNaN(parseInt(newNode.outputs))) {
|
||||
// The node declares outputs in its defaults, but has not got a valid value
|
||||
// Defer to the length of the wires array
|
||||
newNode.outputs = newNode.wires.length;
|
||||
} else {
|
||||
// If 'wires' is longer than outputs, clip wires
|
||||
console.log("Warning: node.wires longer than node.outputs - trimming wires:", node.id, " wires:", node.wires.length, " outputs:", node.outputs);
|
||||
// TODO: Pas dans l'autre sens ?
|
||||
newNode.wires = newNode.wires.slice(0, newNode.outputs);
|
||||
}
|
||||
// The node declares outputs in its defaults, but has not got a valid value
|
||||
// Defer to the length of the wires array
|
||||
if (isNaN(newNode.outputs)) {
|
||||
newNode.outputs = newNode.wires.length;
|
||||
} else if (newNode.wires.length > newNode.outputs) {
|
||||
// If 'wires' is longer than outputs, clip wires
|
||||
console.log("Warning: node.wires longer than node.outputs - trimming wires:", node.id, " wires:", node.wires.length, " outputs:", node.outputs);
|
||||
// TODO: Pas dans l'autre sens ?
|
||||
newNode.wires = newNode.wires.slice(0, newNode.outputs);
|
||||
}
|
||||
|
||||
// Copy node user properties
|
||||
|
Loading…
x
Reference in New Issue
Block a user