()
| 310 | } |
| 311 | |
| 312 | updateChildren() { |
| 313 | const newData = this.getChildren() || []; |
| 314 | const oldData = this.childNodes.map((node) => node.data); |
| 315 | |
| 316 | const newDataMap = {}; |
| 317 | const newNodes = []; |
| 318 | |
| 319 | newData.forEach((item, index) => { |
| 320 | if (item[NODE_KEY]) { |
| 321 | newDataMap[item[NODE_KEY]] = { index, data: item }; |
| 322 | } else { |
| 323 | newNodes.push({ index, data: item }); |
| 324 | } |
| 325 | }); |
| 326 | |
| 327 | oldData.forEach((item) => { |
| 328 | if (!newDataMap[item[NODE_KEY]]) this.removeChildByData(item); |
| 329 | }); |
| 330 | |
| 331 | newNodes.forEach(({ index, data }) => { |
| 332 | this.insertChild({ data }, index); |
| 333 | }); |
| 334 | |
| 335 | this.updateLeafState(); |
| 336 | } |
| 337 | |
| 338 | loadData(callback, defaultProps = {}) { |
| 339 | if (this.store.lazy === true && this.store.load && !this.loaded && !this.loading) { |
no test coverage detected