1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 10:51:44 +02:00

Allow Node.forEachDescendant to exit early

This commit is contained in:
Samy Pessé
2016-11-03 12:05:16 +01:00
parent 6f90515c96
commit 663522139c

View File

@@ -170,7 +170,9 @@ const Node = {
forEachDescendant(iterator) { forEachDescendant(iterator) {
return this.nodes.forEach((child, i, nodes) => { return this.nodes.forEach((child, i, nodes) => {
iterator(child, i, nodes) if (iterator(child, i, nodes) === false) {
return false
}
if (child.kind != 'text') child.forEachDescendant(iterator) if (child.kind != 'text') child.forEachDescendant(iterator)
}) })
}, },