You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What do you think about having a node.contains(...) method? This would be very helpful, as currently it's possible to create an infinite loop when adding nodes as a sub-node to itself in InfiniteTree.
contains(target) {
const children = this.children
const length = children.length
for (let i = 0; i < length; i++) {
const node = children[i]
if (node === target) return true
if (node.children) {
const result = node.contains(target)
if (result) return result
}
}
}
The text was updated successfully, but these errors were encountered:
It's fine with me to add a node.contains() method. From your example, traversing up through its ancestors should be more efficient since the target node has a parent link:
What do you think about having a node.contains(...) method? This would be very helpful, as currently it's possible to create an infinite loop when adding nodes as a sub-node to itself in InfiniteTree.
The text was updated successfully, but these errors were encountered: