[Bug] Fix remove of floatingLinks (#792)

Resolves https://github.com/Comfy-Org/litegraph.js/issues/791

This PR fixes removal of floating links.

---------

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
This commit is contained in:
Chenlei Hu
2025-03-16 18:13:24 -04:00
committed by GitHub
parent dbc605e4da
commit 94b9ecec71
5 changed files with 96 additions and 1 deletions

View File

@@ -32,6 +32,18 @@ describe("LGraph", () => {
const fromOldSchema = new LGraph(oldSchemaGraph)
expect(fromOldSchema).toMatchSnapshot("oldSchemaGraph")
})
describe("Reroutes", () => {
test("Floating reroute should be removed when node and link are removed", ({ expect, floatingLinkGraph }) => {
const graph = new LGraph(floatingLinkGraph)
expect(graph.nodes.length).toBe(1)
graph.remove(graph.nodes[0])
expect(graph.nodes.length).toBe(0)
expect(graph.links.size).toBe(0)
expect(graph.floatingLinks.size).toBe(0)
expect(graph.reroutes.size).toBe(0)
})
})
})
describe("Legacy LGraph Compatibility Layer", () => {