Skip to content

Commit

Permalink
Fixed the regression in addChildNodes (#24)
Browse files Browse the repository at this point in the history
* Fixed the regression in addChildNodes

* wip

* rebuilt dist & examples

* applied feedback
  • Loading branch information
acierto authored and cheton committed Jan 30, 2018
1 parent ca7829d commit 0ca1dc1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions dist/infinite-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1348,9 +1348,11 @@ var InfiniteTree = function (_events$EventEmitter) {
} else {
var parentOffset = this.nodes.indexOf(parentNode);
if (parentOffset >= 0) {
// Update nodes & rows
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
if (parentNode.state.open === true) {
// Update nodes & rows
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
}

// Update the row corresponding to the parent node
this.rows[parentOffset] = this.options.rowRenderer(parentNode, this.options);
Expand Down
2 changes: 1 addition & 1 deletion dist/infinite-tree.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/examples.js

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/infinite-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,11 @@ class InfiniteTree extends events.EventEmitter {
} else {
const parentOffset = this.nodes.indexOf(parentNode);
if (parentOffset >= 0) {
// Update nodes & rows
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
if (parentNode.state.open === true) {
// Update nodes & rows
this.nodes.splice.apply(this.nodes, [parentOffset + 1, deleteCount].concat(nodes));
this.rows.splice.apply(this.rows, [parentOffset + 1, deleteCount].concat(rows));
}

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

0 comments on commit 0ca1dc1

Please sign in to comment.