diff --git a/src/lib/litegraph/src/LGraphNode.test.ts b/src/lib/litegraph/src/LGraphNode.test.ts index 6682d274c..5b498dac3 100644 --- a/src/lib/litegraph/src/LGraphNode.test.ts +++ b/src/lib/litegraph/src/LGraphNode.test.ts @@ -137,6 +137,13 @@ describe('LGraphNode', () => { expect(node.id).toEqual(1) expect(node.outputs.length).toEqual(1) }) + test('should not allow configuring id to -1', () => { + const graph = new LGraph() + const node = new LGraphNode('TestNode') + graph.add(node) + node.configure(getMockISerialisedNode({ id: -1 })) + expect(node.id).not.toBe(-1) + }) describe('Disconnect I/O Slots', () => { test('should disconnect input correctly', () => { diff --git a/src/lib/litegraph/src/LGraphNode.ts b/src/lib/litegraph/src/LGraphNode.ts index 1ff503cdc..d4d50537c 100644 --- a/src/lib/litegraph/src/LGraphNode.ts +++ b/src/lib/litegraph/src/LGraphNode.ts @@ -785,6 +785,7 @@ export class LGraphNode if (this.graph) { this.graph._version++ } + if (info.id === -1) info.id = this.id for (const j in info) { if (j == 'properties') { // i don't want to clone properties, I want to reuse the old container