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

Use Node.forEachDescendant in Node.findDescendantDeep

This commit is contained in:
Samy Pessé
2016-11-03 17:03:46 +01:00
parent 738383cb3b
commit af911fd0ff

View File

@@ -159,18 +159,16 @@ const Node = {
*/
findDescendantDeep(iterator) {
let descendantFound = null
let found
const found = this.nodes.find(node => {
if (node.kind != 'text') {
descendantFound = node.findDescendantDeep(iterator)
return descendantFound || iterator(node)
this.forEachDescendant(node => {
if (iterator(node)) {
found = node
return false
}
return iterator(node) ? node : null
})
return descendantFound || found
return found
},
/**