diff --git a/src/project/Project.js b/src/project/Project.js index dfeb4830..12bd3fbf 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -84,7 +84,7 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ // DOCS: Project#clear() clear: function() { - for (var i = 0; i < this.layers.length; i++) + for (var i = this.layers.length - 1; i >= 0; i--) this.layers[i].remove(); this.symbols = []; }, diff --git a/test/tests/Project.js b/test/tests/Project.js index 65f7c252..12458205 100644 --- a/test/tests/Project.js +++ b/test/tests/Project.js @@ -23,4 +23,13 @@ test('activate()', function() { equals(function() { return secondDoc.activeLayer.children.length == 0; }, true); -}); \ No newline at end of file +}); + +test('clear()', function() { + var project = new Project(); + new Layer(); + new Layer(); + equals(project.layers.length, 3); + project.clear(); + equals(project.layers.length, 0); +});