Keep original data pointers and correct if clause

This commit is contained in:
Sergio Crisostomo 2017-10-24 09:30:09 +02:00
parent d44420be72
commit 0a8f9b43f6

View file

@ -44,13 +44,13 @@
data () { data () {
return { return {
prefixCls: prefixCls, prefixCls: prefixCls,
stateTree: JSON.parse(JSON.stringify(this.data)), stateTree: this.data,
flatState: [], flatState: [],
}; };
}, },
watch: { watch: {
data(){ data(){
this.stateTree = JSON.parse(JSON.stringify(this.data)); this.stateTree = this.data;
this.flatState = this.compileFlatState(); this.flatState = this.compileFlatState();
this.rebuildTree(); this.rebuildTree();
} }
@ -109,7 +109,7 @@
this.updateTreeDown(node, {checked: true}); this.updateTreeDown(node, {checked: true});
// propagate upwards // propagate upwards
const parentKey = this.flatState[node.nodeKey].parent; const parentKey = this.flatState[node.nodeKey].parent;
if (!parentKey) return; if (!parentKey && parentKey !== 0) return;
const parent = this.flatState[parentKey].node; const parent = this.flatState[parentKey].node;
const childHasCheckSetter = typeof node.checked != 'undefined' && node.checked; const childHasCheckSetter = typeof node.checked != 'undefined' && node.checked;
if (childHasCheckSetter && parent.checked != node.checked) { if (childHasCheckSetter && parent.checked != node.checked) {