diff --git a/examples/Paperjs.org/MetaBalls.html b/examples/Paperjs.org/MetaBalls.html index 86348bf0..8f9fe858 100644 --- a/examples/Paperjs.org/MetaBalls.html +++ b/examples/Paperjs.org/MetaBalls.html @@ -41,7 +41,7 @@ var connections = new Group(); function generateConnections(paths) { // Remove the last connection paths: - connections.children = []; + connections.removeChildren(); for (var i = 0, l = paths.length; i < l; i++) { for (var j = i - 1; j >= 0; j--) { diff --git a/examples/Paperjs.org/Voronoi.html b/examples/Paperjs.org/Voronoi.html index 6097c334..d556d663 100644 --- a/examples/Paperjs.org/Voronoi.html +++ b/examples/Paperjs.org/Voronoi.html @@ -31,7 +31,7 @@ } function renderDiagram() { - project.activeLayer.children = []; + project.activeLayer.removeChildren(); var diagram = voronoi.compute(sites, bbox); if (diagram) { for (var i = 0, l = sites.length; i < l; i++) { diff --git a/src/item/Item.js b/src/item/Item.js index 4ddb95b4..4bcf8a70 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -2528,14 +2528,21 @@ new function() { // Injection scope for hit-test functions shared with project var owner = this._getOwner(), project = this._project, index = this._index; - if (owner && index != null) { - // Only required for layers, but not enough to merit an override. - if (project._activeLayer === this) - project._activeLayer = this.getNextSibling() - || this.getPreviousSibling(); + if (owner) { + // Handle index separately from owner: There are situations where + // the item is already removed from its list through Base.splice() + // and index set to undefined, but the owner is still set, + // e.g. in #removeChildren(): + if (index != null) { + // Only required for layers but not enough to merit an override. + if (project._activeLayer === this) + project._activeLayer = this.getNextSibling() + || this.getPreviousSibling(); + Base.splice(owner._children, null, index, 1); + } + // Handle named children separately from index: if (this._name) this._removeNamed(); - Base.splice(owner._children, null, index, 1); this._installEvents(false); // Notify self of the insertion change. We only need this // notification if we're tracking changes for now. diff --git a/src/item/Project.js b/src/item/Project.js index 1cab04f0..d9b74857 100644 --- a/src/item/Project.js +++ b/src/item/Project.js @@ -855,8 +855,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ // should not set this. updateMatrix: true }); - for (var i = 0, l = children.length; i < l; i++) + for (var i = 0, l = children.length; i < l; i++) { children[i].draw(ctx, param); + } ctx.restore(); // Draw the selection of the selected items in the project: @@ -866,8 +867,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ var items = this._selectedItems, size = this._scope.settings.handleSize, version = this._updateVersion; - for (var id in items) + for (var id in items) { items[id]._drawSelection(ctx, matrix, size, items, version); + } ctx.restore(); } }