Fix set wrong map value for list remove item op.

This commit is contained in:
Ulion 2021-02-09 10:42:12 +08:00
parent e7648b083d
commit 16cf59536f

View File

@ -55,18 +55,16 @@ const removeNodeOp = (op: Automerge.Diff) => (map: any, doc: Element) => {
throw new TypeError('Target is not found!') throw new TypeError('Target is not found!')
} }
if (!map.hasOwnProperty(obj)) {
map[obj] = target
}
if (!Number.isInteger(index)) { if (!Number.isInteger(index)) {
throw new TypeError('Index is not a number') throw new TypeError('Index is not a number')
} }
if (parent?.children?.[index as number]) { if (parent?.children?.[index as number]) {
parent.children.splice(index, 1) parent.children.splice(index, 1)
map[obj] = parent?.children
} else if (parent?.[index as number]) { } else if (parent?.[index as number]) {
parent.splice(index, 1) parent.splice(index, 1)
map[obj] = parent
} }
return { return {