Fix setNodes undefined value since automerge does not handle undefined value correctly. (#49)

This commit is contained in:
Ulion 2021-01-15 21:22:28 +08:00 committed by GitHub
parent d141da4430
commit ef35812723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,12 @@ const setNode = (doc: SyncValue, op: SetNodeOperation): SyncValue => {
const { newProperties } = op
for (let key in newProperties) {
node[key] = newProperties[key]
const value = newProperties[key]
if (value !== undefined) {
node[key] = value
} else {
delete node[key]
}
}
return doc