Skip to content

Commit 0ca1dc1

Browse files
aciertocheton
authored andcommitted
Fixed the regression in addChildNodes (#24)
* Fixed the regression in addChildNodes * wip * rebuilt dist & examples * applied feedback
1 parent ca7829d commit 0ca1dc1

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

dist/infinite-tree.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,9 +1348,11 @@ var InfiniteTree = function (_events$EventEmitter) {
13481348
} else {
13491349
var parentOffset = this.nodes.indexOf(parentNode);
13501350
if (parentOffset >= 0) {
1351-
// Update nodes & rows
1352-
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
1353-
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
1351+
if (parentNode.state.open === true) {
1352+
// Update nodes & rows
1353+
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
1354+
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
1355+
}
13541356

13551357
// Update the row corresponding to the parent node
13561358
this.rows[parentOffset] = this.options.rowRenderer(parentNode, this.options);

dist/infinite-tree.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/examples.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/infinite-tree.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,11 @@ class InfiniteTree extends events.EventEmitter {
487487
} else {
488488
const parentOffset = this.nodes.indexOf(parentNode);
489489
if (parentOffset >= 0) {
490-
// Update nodes & rows
491-
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
492-
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
490+
if (parentNode.state.open === true) {
491+
// Update nodes & rows
492+
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
493+
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
494+
}
493495

494496
// Update the row corresponding to the parent node
495497
this.rows[parentOffset] = this.options.rowRenderer(parentNode, this.options);

0 commit comments

Comments
 (0)