mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-02 11:42:53 +02:00
Use Node.forEachDescendant in Node.findDescendantDeep
This commit is contained in:
@@ -159,18 +159,16 @@ const Node = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
findDescendantDeep(iterator) {
|
findDescendantDeep(iterator) {
|
||||||
let descendantFound = null
|
let found
|
||||||
|
|
||||||
const found = this.nodes.find(node => {
|
this.forEachDescendant(node => {
|
||||||
if (node.kind != 'text') {
|
if (iterator(node)) {
|
||||||
descendantFound = node.findDescendantDeep(iterator)
|
found = node
|
||||||
return descendantFound || iterator(node)
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return iterator(node) ? node : null
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return descendantFound || found
|
return found
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user