1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-22 23:12:52 +02:00

simplify parent dirty key logic

This commit is contained in:
Ian Storm Taylor
2018-09-21 15:03:16 -07:00
parent 4e9d262f9b
commit 75ef8a5232

View File

@@ -420,25 +420,22 @@ function getDirtyKeys(operation, newValue, oldValue) {
case 'insert_node': { case 'insert_node': {
const table = node.getKeysToPathsTable() const table = node.getKeysToPathsTable()
const parent = newDocument.assertParent(path) const keys = Object.keys(table)
const keys = [parent.key, ...Object.keys(table)]
return keys return keys
} }
case 'split_node': { case 'split_node': {
const nextPath = PathUtils.increment(path) const nextPath = PathUtils.increment(path)
const parent = newDocument.assertParent(path)
const target = newDocument.assertNode(path) const target = newDocument.assertNode(path)
const split = newDocument.assertNode(nextPath) const split = newDocument.assertNode(nextPath)
const keys = [parent.key, target.key, split.key] const keys = [target.key, split.key]
return keys return keys
} }
case 'merge_node': { case 'merge_node': {
const previousPath = PathUtils.decrement(path) const previousPath = PathUtils.decrement(path)
const parent = newDocument.assertParent(path)
const merged = newDocument.assertNode(previousPath) const merged = newDocument.assertNode(previousPath)
const keys = [parent.key, merged.key] const keys = [merged.key]
return keys return keys
} }