From a7b9efbd293484acdbf027193cf18515a0756992 Mon Sep 17 00:00:00 2001 From: Arash <38922203+arashsheyda@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:59:39 -0600 Subject: [PATCH] fix(state-editor): update deepSync function (#713) --- .../devtools/client/components/StateEditor.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/devtools/client/components/StateEditor.vue b/packages/devtools/client/components/StateEditor.vue index b1da993c3..fe86ca3a8 100644 --- a/packages/devtools/client/components/StateEditor.vue +++ b/packages/devtools/client/components/StateEditor.vue @@ -22,7 +22,7 @@ function clone() { error.value = undefined try { if (props.state) - proxy.value = JSON.parse(JSON.stringify(props.state)) + proxy.value = JSON.parse(JSON.stringify(props.state || {})) else if (typeof props.state === 'number' || typeof props.state !== 'string') proxy.value = props.state } @@ -50,15 +50,15 @@ onMounted(() => { }) function deepSync(from: any, to: any) { - for (const key in from) { - if (from[key] === null) - to[key] = null - else if (Array.isArray(from[key])) - to[key] = from[key].slice() - else if (typeof from[key] === 'object') - deepSync(from[key], to[key]) + // const fromRevision = from[0] + const fromValue = from[1] + for (const key in fromValue) { + if (Array.isArray(fromValue[key])) + to[key] = fromValue[key].slice() + else if (typeof fromValue[key] === 'object') + deepSync(fromValue[key], to[key]) else - to[key] = from[key] + to[key] = fromValue[key] } }