Commit d97555bd authored by dive2Pro's avatar dive2Pro Committed by hetech

Tree: fixed `default-checked-keys` display wrong (#13349)

* fix: 12383 Tree in lazy mode set child node 'default-checked-keys', display wrong:All nodes are fulfilled

* 添加测试

* fix code style

* update style
parent 9738054d
......@@ -465,6 +465,7 @@ export default class Node {
this.doCreateChildren(children, defaultProps);
this.updateLeafState();
reInitChecked(this);
if (callback) {
callback.call(this, children);
}
......
......@@ -299,6 +299,36 @@ describe('Tree', () => {
expect(vm.$el.querySelectorAll('.el-checkbox .is-checked').length).to.equal(1);
});
it('defaultCheckedKeys & lazy, checked children length as expected', () => {
vm = getTreeVm(':load="loadNode" :props="defaultProps" :default-checked-keys="defaultCheckedKeys" node-key="id" :default-expanded-keys="[1]" lazy show-checkbox ', {
created() {
this.defaultCheckedKeys = [2, 3];
},
methods: {
loadNode(node, resolve) {
if (node.level === 0) {
return resolve([{ label: 'head', id: 1} ]);
}
return resolve([
{
label: '#1',
id: 2
},
{
label: '#3',
id: 3
},
{
label: '$4',
id: 5
}
]);
}
}
});
expect(vm.$el.querySelectorAll('.el-checkbox.is-checked').length).to.equal(2);
});
it('show checkbox', done => {
vm = getTreeVm(':props="defaultProps" show-checkbox');
const tree = vm.$children[0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment