From c4c2b8e9f19117d89f87c457ab4dbf4cd64bfada Mon Sep 17 00:00:00 2001 From: rgthree Date: Sun, 17 Sep 2023 11:51:02 -0400 Subject: [PATCH] Only connect to any when there's inputs. --- ts/base_any_input_connected_node.ts | 10 ++++++---- web/base_any_input_connected_node.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ts/base_any_input_connected_node.ts b/ts/base_any_input_connected_node.ts index 8f866b5..c4cd873 100644 --- a/ts/base_any_input_connected_node.ts +++ b/ts/base_any_input_connected_node.ts @@ -286,10 +286,12 @@ LGraphNode.prototype.connectByType = function connectByType( optsIn: string): T | null { // If we're droppiong on a node, and the last input is free and an "*" type, then connect there // first... - for (const [index, input] of sourceNode.inputs.entries()) { - if (!input.link && input.type === '*') { - this.connect(slot, sourceNode, index); - return null; + if (sourceNode.inputs) { + for (const [index, input] of sourceNode.inputs.entries()) { + if (!input.link && input.type === '*') { + this.connect(slot, sourceNode, index); + return null; + } } } return (oldLGraphNodeConnectByType && oldLGraphNodeConnectByType.call(this, slot, sourceNode, sourceSlotType, optsIn) || null) as T; diff --git a/web/base_any_input_connected_node.js b/web/base_any_input_connected_node.js index a25e11f..1ea490f 100644 --- a/web/base_any_input_connected_node.js +++ b/web/base_any_input_connected_node.js @@ -160,10 +160,12 @@ export class BaseAnyInputConnectedNode extends RgthreeBaseNode { } const oldLGraphNodeConnectByType = LGraphNode.prototype.connectByType; LGraphNode.prototype.connectByType = function connectByType(slot, sourceNode, sourceSlotType, optsIn) { - for (const [index, input] of sourceNode.inputs.entries()) { - if (!input.link && input.type === '*') { - this.connect(slot, sourceNode, index); - return null; + if (sourceNode.inputs) { + for (const [index, input] of sourceNode.inputs.entries()) { + if (!input.link && input.type === '*') { + this.connect(slot, sourceNode, index); + return null; + } } } return (oldLGraphNodeConnectByType && oldLGraphNodeConnectByType.call(this, slot, sourceNode, sourceSlotType, optsIn) || null);