diff --git a/src/components/tree/tree.vue b/src/components/tree/tree.vue index ac4c381..fd4f954 100644 --- a/src/components/tree/tree.vue +++ b/src/components/tree/tree.vue @@ -81,18 +81,19 @@ methods: { compileFlatState () { // so we have always a relation parent/children of each node let keyCounter = 0; + let childrenKey = this.childrenKey; const flatTree = []; function flattenChildren(node, parent) { node.nodeKey = keyCounter++; flatTree[node.nodeKey] = { node: node, nodeKey: node.nodeKey }; if (typeof parent != 'undefined') { flatTree[node.nodeKey].parent = parent.nodeKey; - flatTree[parent.nodeKey].children.push(node.nodeKey); + flatTree[parent.nodeKey][childrenKey].push(node.nodeKey); } - if (node.children) { - flatTree[node.nodeKey].children = []; - node.children.forEach(child => flattenChildren(child, node)); + if (node[childrenKey]) { + flatTree[node.nodeKey][childrenKey] = []; + node[childrenKey].forEach(child => flattenChildren(child, node)); } } this.stateTree.forEach(rootNode => { @@ -109,11 +110,11 @@ if (node.checked == parent.checked && node.indeterminate == parent.indeterminate) return; // no need to update upwards if (node.checked == true) { - this.$set(parent, 'checked', parent.children.every(node => node.checked)); + this.$set(parent, 'checked', parent[this.childrenKey].every(node => node.checked)); this.$set(parent, 'indeterminate', !parent.checked); } else { this.$set(parent, 'checked', false); - this.$set(parent, 'indeterminate', parent.children.some(node => node.checked || node.indeterminate)); + this.$set(parent, 'indeterminate', parent[this.childrenKey].some(node => node.checked || node.indeterminate)); } this.updateTreeUp(parentKey); }, @@ -144,8 +145,8 @@ for (let key in changes) { this.$set(node, key, changes[key]); } - if (node.children) { - node.children.forEach(child => { + if (node[this.childrenKey]) { + node[this.childrenKey].forEach(child => { this.updateTreeDown(child, changes); }); } -- libgit2 0.21.4