mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Fix project.clear() so it removes all layers properly.
This commit is contained in:
parent
ca0513b1b2
commit
68626ca62b
2 changed files with 11 additions and 2 deletions
|
@ -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 = [];
|
||||||
},
|
},
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue