mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #4808 from GogoVega/fix-invalid-outputs
Fix a node with an invalid number of outputs
This commit is contained in:
		| @@ -2349,29 +2349,31 @@ RED.nodes = (function() { | ||||
|                             node.type = "unknown"; | ||||
|                         } | ||||
|                         if (node._def.category != "config") { | ||||
|                             if (n.hasOwnProperty('inputs')) { | ||||
|                                 node.inputs = n.inputs; | ||||
|                             if (n.hasOwnProperty('inputs') && def.defaults.hasOwnProperty("inputs")) { | ||||
|                                 node.inputs = parseInt(n.inputs, 10); | ||||
|                                 node._config.inputs = JSON.stringify(n.inputs); | ||||
|                             } else { | ||||
|                                 node.inputs = node._def.inputs; | ||||
|                             } | ||||
|                             if (n.hasOwnProperty('outputs')) { | ||||
|                                 node.outputs = n.outputs; | ||||
|                             if (n.hasOwnProperty('outputs') && def.defaults.hasOwnProperty("outputs")) { | ||||
|                                 node.outputs = parseInt(n.outputs, 10); | ||||
|                                 node._config.outputs = JSON.stringify(n.outputs); | ||||
|                             } else { | ||||
|                                 node.outputs = node._def.outputs; | ||||
|                             } | ||||
|                             if (node.hasOwnProperty('wires') && node.wires.length > node.outputs) { | ||||
|                                 if (!node._def.defaults.hasOwnProperty("outputs") || !isNaN(parseInt(n.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); | ||||
|                                     node.wires = node.wires.slice(0,node.outputs); | ||||
|                                 } else { | ||||
|                                     // The node declares outputs in its defaults, but has not got a valid value | ||||
|                                     // Defer to the length of the wires array | ||||
|  | ||||
|                             // The node declares outputs in its defaults, but has not got a valid value | ||||
|                             // Defer to the length of the wires array | ||||
|                             if (node.hasOwnProperty('wires')) { | ||||
|                                 if (isNaN(node.outputs)) { | ||||
|                                     node.outputs = node.wires.length; | ||||
|                                 } else if (node.wires.length > node.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); | ||||
|                                     node.wires = node.wires.slice(0, node.outputs); | ||||
|                                 } | ||||
|                             } | ||||
|  | ||||
|                             for (d in node._def.defaults) { | ||||
|                                 if (node._def.defaults.hasOwnProperty(d) && d !== 'inputs' && d !== 'outputs') { | ||||
|                                     node[d] = n[d]; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user