fix: use JSON clone instead of structuredClone for Vue reactive proxies
structuredClone cannot clone Vue reactive Proxy objects (DataCloneError). EventModel contains only plain data, so JSON round-trip is safe and lossless. Verified: organize, toggle, undo, download all work correctly.
This commit is contained in:
@@ -30,12 +30,13 @@ export function createEvent(overrides = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deep-clone an event via structuredClone (available in modern browsers
|
* Deep-clone an event (or any plain-data object).
|
||||||
* and Node 17+). Falls back to JSON round-trip for older environments.
|
*
|
||||||
|
* Uses JSON round-trip rather than structuredClone because events may be
|
||||||
|
* wrapped in Vue reactive proxies, which structuredClone cannot handle.
|
||||||
|
* EventModel contains only plain data (strings, arrays, nested objects),
|
||||||
|
* so JSON cloning is safe and lossless here.
|
||||||
*/
|
*/
|
||||||
export function cloneEvent(ev) {
|
export function cloneEvent(ev) {
|
||||||
if (typeof structuredClone === 'function') {
|
|
||||||
return structuredClone(ev)
|
|
||||||
}
|
|
||||||
return JSON.parse(JSON.stringify(ev))
|
return JSON.parse(JSON.stringify(ev))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user