Skip to content

Commit

Permalink
fix(state-editor): update deepSync function (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
arashsheyda authored Aug 26, 2024
1 parent 8b08e56 commit a7b9efb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/devtools/client/components/StateEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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]
}
}
Expand Down

0 comments on commit a7b9efb

Please sign in to comment.