Only connect to any when there's inputs.

This commit is contained in:
rgthree
2023-09-17 11:51:02 -04:00
parent 7a11b8cf28
commit c4c2b8e9f1
2 changed files with 12 additions and 8 deletions
+6 -4
View File
@@ -286,10 +286,12 @@ LGraphNode.prototype.connectByType = function connectByType<T = any>(
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;
+6 -4
View File
@@ -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);