From 6dd3620dd699e65790914de5bcf03c2fb195a713 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Sun, 9 Feb 2020 23:57:14 +0100 Subject: [PATCH] fix cloning element.points (#744) --- src/element/newElement.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/element/newElement.ts b/src/element/newElement.ts index 314493f2c..13e37f5d2 100644 --- a/src/element/newElement.ts +++ b/src/element/newElement.ts @@ -65,8 +65,13 @@ export function newTextElement( export function duplicateElement(element: ReturnType) { 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();