I'm trying to clone an Vertex object in mxgraph, to edit the coordinates without changing the original Vertex, but I get the Error "Uncaught TypeError: terminal.insertEdge is not a function" in the console and none of the vertices, from that point on, render.
I tried different Cloning Methods like:
vertexClone = structuredClone(vertex); vertexClone = JSON.parse(JSON.stringify(vertex)); vertexClone = Object.assign({}, vertex); vertexClone = { ...vertex}; But when further using the VertexClone object, I get the TypeError in my console.
structuredClonedoes not duplicate prototypes! Neither doesObject.assign, or any of the methods you provided. JSON cannot serialise methods (and thereforprototypes), assign only does it for own properties and destructuring does the same thing. In order to this this you will have to reconstruct it or manually make a cloning method.