Skip to content

Commit

Permalink
fix remove all breaking insert, close #10
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Nov 5, 2013
1 parent 615af09 commit 02164f7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rbush.js
Expand Up @@ -418,9 +418,13 @@ rbush.prototype = {
_condense: function (path) {
// go through the path, removing empty nodes and updating bboxes
for (var i = path.length - 1, parent; i >= 0; i--) {
if (i > 0 && path[i].children.length === 0) {
parent = path[i - 1].children;
parent.splice(parent.indexOf(path[i]), 1);
if (path[i].children.length === 0) {
if (i > 0) {
parent = path[i - 1].children;
parent.splice(parent.indexOf(path[i]), 1);
} else {
this.clear();
}
} else {
this._calcBBox(path[i]);
}
Expand Down

0 comments on commit 02164f7

Please sign in to comment.