Fix project.clear() so it removes all layers properly.

This commit is contained in:
Chris Barmonde 2013-06-20 20:14:47 -06:00
parent ca0513b1b2
commit 68626ca62b
2 changed files with 11 additions and 2 deletions

View file

@ -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 = [];
},

View file

@ -24,3 +24,12 @@ test('activate()', function() {
return secondDoc.activeLayer.children.length == 0;
}, true);
});
test('clear()', function() {
var project = new Project();
new Layer();
new Layer();
equals(project.layers.length, 3);
project.clear();
equals(project.layers.length, 0);
});