Browse Source

fix cloning element.points (#744)

David Luzar 5 years ago
parent
commit
6dd3620dd6
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/element/newElement.ts

+ 6 - 1
src/element/newElement.ts

@@ -65,8 +65,13 @@ export function newTextElement(
 export function duplicateElement(element: ReturnType<typeof newElement>) {
   const copy = {
     ...element,
-    points: JSON.parse(JSON.stringify(element.points)),
   };
+  if ("points" in copy) {
+    copy.points = Array.isArray(element.points)
+      ? JSON.parse(JSON.stringify(element.points))
+      : element.points;
+  }
+
   delete copy.shape;
   copy.id = nanoid();
   copy.seed = randomSeed();