1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| export const NODE_KEY = '$treeNodeId';
|
| export const markNodeData = function(node, data) {
| if (!data || data[NODE_KEY]) return;
| Object.defineProperty(data, NODE_KEY, {
| value: node.id,
| enumerable: false,
| configurable: false,
| writable: false
| });
| };
|
| export const getNodeKey = function(key, data) {
| if (!key) return data[NODE_KEY];
| return data[key];
| };
|
| export const findNearestComponent = (element, componentName) => {
| let target = element;
| while (target && target.tagName !== 'BODY') {
| if (target.__vue__ && target.__vue__.$options.name === componentName) {
| return target.__vue__;
| }
| target = target.parentNode;
| }
| return null;
| };
|
|