From be90308f23184539b08c35304f224298c9db9a31 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Fri, 25 Oct 2024 18:13:00 +0900 Subject: [PATCH] Add safeStructuredClone function comment --- src/ts/polyfill.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ts/polyfill.ts b/src/ts/polyfill.ts index c0b0095c..a827da6a 100644 --- a/src/ts/polyfill.ts +++ b/src/ts/polyfill.ts @@ -3,6 +3,10 @@ import { Buffer as BufferPolyfill } from 'buffer' import { polyfill as dragPolyfill} from "mobile-drag-drop" import {scrollBehaviourDragImageTranslateOverride} from 'mobile-drag-drop/scroll-behaviour' +/** + * Safe variant of structuredClone for svelte 5 states + * if structuredClone is not available, it will use JSON.parse(JSON.stringify(data)) instead +*/ function safeStructuredClone(data:T):T{ try { return structuredClone(data)