From fdda5c7e1b16e5d76ac547d04507c0b0f8846208 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Sat, 1 Feb 2025 13:04:06 +0800 Subject: [PATCH] feat: prefer structuredClone api for cloning #980 --- src/editor/utils/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/editor/utils/index.ts b/src/editor/utils/index.ts index cf40bcbf..6c610133 100644 --- a/src/editor/utils/index.ts +++ b/src/editor/utils/index.ts @@ -56,6 +56,9 @@ export function deepCloneOmitKeys(obj: T, omitKeys: (keyof K)[]): T { } export function deepClone(obj: T): T { + if (typeof structuredClone === 'function') { + return structuredClone(obj) + } if (!obj || typeof obj !== 'object') { return obj }