Commit 0a8f9b43f6497c8dc0376e738b314304f12ed770
1 parent
d44420be
Keep original data pointers and correct if clause
Showing
1 changed file
with
3 additions
and
3 deletions
Show diff stats
src/components/tree/tree.vue
@@ -44,13 +44,13 @@ | @@ -44,13 +44,13 @@ | ||
44 | data () { | 44 | data () { |
45 | return { | 45 | return { |
46 | prefixCls: prefixCls, | 46 | prefixCls: prefixCls, |
47 | - stateTree: JSON.parse(JSON.stringify(this.data)), | 47 | + stateTree: this.data, |
48 | flatState: [], | 48 | flatState: [], |
49 | }; | 49 | }; |
50 | }, | 50 | }, |
51 | watch: { | 51 | watch: { |
52 | data(){ | 52 | data(){ |
53 | - this.stateTree = JSON.parse(JSON.stringify(this.data)); | 53 | + this.stateTree = this.data; |
54 | this.flatState = this.compileFlatState(); | 54 | this.flatState = this.compileFlatState(); |
55 | this.rebuildTree(); | 55 | this.rebuildTree(); |
56 | } | 56 | } |
@@ -109,7 +109,7 @@ | @@ -109,7 +109,7 @@ | ||
109 | this.updateTreeDown(node, {checked: true}); | 109 | this.updateTreeDown(node, {checked: true}); |
110 | // propagate upwards | 110 | // propagate upwards |
111 | const parentKey = this.flatState[node.nodeKey].parent; | 111 | const parentKey = this.flatState[node.nodeKey].parent; |
112 | - if (!parentKey) return; | 112 | + if (!parentKey && parentKey !== 0) return; |
113 | const parent = this.flatState[parentKey].node; | 113 | const parent = this.flatState[parentKey].node; |
114 | const childHasCheckSetter = typeof node.checked != 'undefined' && node.checked; | 114 | const childHasCheckSetter = typeof node.checked != 'undefined' && node.checked; |
115 | if (childHasCheckSetter && parent.checked != node.checked) { | 115 | if (childHasCheckSetter && parent.checked != node.checked) { |