Skip to content

Commit a7b9efb

Browse files
authored
fix(state-editor): update deepSync function (#713)
1 parent 8b08e56 commit a7b9efb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/devtools/client/components/StateEditor.vue

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function clone() {
2222
error.value = undefined
2323
try {
2424
if (props.state)
25-
proxy.value = JSON.parse(JSON.stringify(props.state))
25+
proxy.value = JSON.parse(JSON.stringify(props.state || {}))
2626
else if (typeof props.state === 'number' || typeof props.state !== 'string')
2727
proxy.value = props.state
2828
}
@@ -50,15 +50,15 @@ onMounted(() => {
5050
})
5151
5252
function deepSync(from: any, to: any) {
53-
for (const key in from) {
54-
if (from[key] === null)
55-
to[key] = null
56-
else if (Array.isArray(from[key]))
57-
to[key] = from[key].slice()
58-
else if (typeof from[key] === 'object')
59-
deepSync(from[key], to[key])
53+
// const fromRevision = from[0]
54+
const fromValue = from[1]
55+
for (const key in fromValue) {
56+
if (Array.isArray(fromValue[key]))
57+
to[key] = fromValue[key].slice()
58+
else if (typeof fromValue[key] === 'object')
59+
deepSync(fromValue[key], to[key])
6060
else
61-
to[key] = from[key]
61+
to[key] = fromValue[key]
6262
}
6363
}
6464

0 commit comments

Comments
 (0)