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() // DOCS: Project#clear()
clear: function() { 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.layers[i].remove();
this.symbols = []; this.symbols = [];
}, },

View file

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