diff --git a/src/canvas/LinkConnector.ts b/src/canvas/LinkConnector.ts index 4747dca62..8176987db 100644 --- a/src/canvas/LinkConnector.ts +++ b/src/canvas/LinkConnector.ts @@ -342,18 +342,24 @@ export class LinkConnector { if (newLink) this.events.dispatch("input-moved", renderLink) } else { const { node: outputNode, fromSlot, fromReroute } = renderLink + // Connect to yourself + if (fromReroute?.id === reroute.id) return + // Identical link + if (fromReroute?.id != null && fromReroute.id === reroute.parentId) return const reroutes = reroute.getReroutes() if (reroutes === null) throw new Error("Reroute loop detected.") - if (reroutes) { + if (reroutes && fromReroute?.id != null) { for (const r of reroutes) { - if (r.id === fromReroute?.id) break + if (r.id === fromReroute.id) break if (r.id === reroute.id) { throw new Error("Cannot connect to reroute that is a parent of the reroute being connected to.") } } + } + if (reroutes) { for (const reroute of reroutes.slice(0, -1).reverse()) { if (reroute.id === fromReroute?.id) break reroute.remove()