diff --git a/src/litegraph.js b/src/litegraph.js index 4780134e..729e759b 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -2348,8 +2348,8 @@ const globalExport = {}; this.title = title || "Unnamed"; this.size = [LiteGraph.NODE_WIDTH, 60]; this.graph = null; - - this._pos = new Float32Array(10, 10); + // Initialize _pos with a Float32Array of length 2, default value [10, 10] + this._pos = new Float32Array([10, 10]); Object.defineProperty(this, "pos", { set: function (v) { diff --git a/test/LGraphNode.test.ts b/test/LGraphNode.test.ts new file mode 100644 index 00000000..1543edf8 --- /dev/null +++ b/test/LGraphNode.test.ts @@ -0,0 +1,12 @@ +import { + LGraphNode, +} from "../dist/litegraph.es.js"; + +describe("LGraphNode", () => { + it("should serialize position correctly", () => { + const node = new LGraphNode("TestNode"); + node.pos = [10, 10]; + expect(node.pos).toEqual(new Float32Array([10, 10])); + expect(node.serialize().pos).toEqual(new Float32Array([10, 10])); + }); +}); \ No newline at end of file