Chore: misc updates

This commit is contained in:
Leopoldthecoder
2017-12-15 13:50:54 +08:00
committed by 杨奕
parent 6497e8c1c1
commit 4a7f3c82ad
11 changed files with 44 additions and 55 deletions

View File

@@ -144,6 +144,18 @@
}
return index;
},
getNodePath(data) {
if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in getNodePath');
const node = this.store.getNode(data);
if (!node) return [];
const path = [node.data];
let parent = node.parent;
while (parent && parent !== this.root) {
path.push(parent.data);
parent = parent.parent;
}
return path.reverse();
},
getCheckedNodes(leafOnly) {
return this.store.getCheckedNodes(leafOnly);
},