diff --git a/js/impact-pack.js b/js/impact-pack.js index 7a46ffba..3fe37cae 100644 --- a/js/impact-pack.js +++ b/js/impact-pack.js @@ -573,7 +573,7 @@ app.registerExtension({ return; } else { - if(nodeData.name == 'ImpactSwitch' && app.graph._nodes_by_id[link_info.origin_id].type == 'Reroute') + if(nodeData.name == 'ImpactSwitch' && app.graph._nodes_by_id[link_info.origin_id]?.type == 'Reroute') this.disconnectInput(link_info.target_slot); // connect input @@ -582,26 +582,30 @@ app.registerExtension({ if(this.inputs[0].type == '*'){ const node = app.graph.getNodeById(link_info.origin_id); - let origin_type = node.outputs[link_info.origin_slot]?.type; - if(link_info.target_slot == 0 && this.inputs.length > 3) { // NOTE: widgets are regarded as input since new front - origin_type = this.inputs[1].type; - node.connect(link_info.origin_slot, node.id, 'input1'); - } - - if(origin_type == '*' && app.graph.getNodeById(link_info.origin_id).slots[link_info.origin_slot].type != '*') { - this.disconnectInput(link_info.target_slot); - return; - } - for(let i in this.inputs) { - let input_i = this.inputs[i]; - if(input_i.name != 'select' && input_i.name != 'sel_mode') - input_i.type = origin_type; - } + // NOTE: node is undefined when subgraph editing mode + if(node) { + let origin_type = node.outputs[link_info.origin_slot]?.type; + if(link_info.target_slot == 0 && this.inputs.length > 3) { // NOTE: widgets are regarded as input since new front + origin_type = this.inputs[1].type; + node.connect(link_info.origin_slot, node.id, 'input1'); + } - this.outputs[0].type = origin_type; - this.outputs[0].label = origin_type; - this.outputs[0].name = origin_type; + if(origin_type == '*' && app.graph.getNodeById(link_info.origin_id).slots[link_info.origin_slot].type != '*') { + this.disconnectInput(link_info.target_slot); + return; + } + + for(let i in this.inputs) { + let input_i = this.inputs[i]; + if(input_i.name != 'select' && input_i.name != 'sel_mode') + input_i.type = origin_type; + } + + this.outputs[0].type = origin_type; + this.outputs[0].label = origin_type; + this.outputs[0].name = origin_type; + } } }