mirror of https://github.com/ElemeFE/element
Tree: fix add node bug in lazy mode (#12265)
parent
7158ddc578
commit
915fc52a1c
|
@ -285,11 +285,13 @@ export default class Node {
|
||||||
|
|
||||||
removeChildByData(data) {
|
removeChildByData(data) {
|
||||||
let targetNode = null;
|
let targetNode = null;
|
||||||
this.childNodes.forEach(node => {
|
|
||||||
if (node.data === data) {
|
for (let i = 0; i < this.childNodes.length; i++) {
|
||||||
targetNode = node;
|
if (this.childNodes[i] === data) {
|
||||||
|
targetNode = this.childNodes[i];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
if (targetNode) {
|
if (targetNode) {
|
||||||
this.removeChild(targetNode);
|
this.removeChild(targetNode);
|
||||||
|
@ -442,9 +444,11 @@ export default class Node {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
oldData.forEach((item) => {
|
if (!this.store.lazy) {
|
||||||
if (!newDataMap[item[NODE_KEY]]) this.removeChildByData(item);
|
oldData.forEach((item) => {
|
||||||
});
|
if (!newDataMap[item[NODE_KEY]]) this.removeChildByData(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
newNodes.forEach(({ index, data }) => {
|
newNodes.forEach(({ index, data }) => {
|
||||||
this.insertChild({ data }, index);
|
this.insertChild({ data }, index);
|
||||||
|
|
Loading…
Reference in New Issue