Fix problem when calling new Group([]).

This commit is contained in:
Jonathan Puckey 2012-11-06 18:07:11 +01:00
parent 33c13b36a3
commit bda7c71fcb
2 changed files with 11 additions and 1 deletions

View file

@ -74,7 +74,7 @@ var Group = this.Group = Item.extend(/** @lends Group# */{
this._children = [];
this._namedChildren = {};
this.addChildren(!items || !Array.isArray(items)
|| typeof items[0] !== 'object' ? arguments : items);
|| items.length && typeof items[0] !== 'object' ? arguments : items);
},
_changed: function(flags) {

View file

@ -23,6 +23,16 @@ test('new Group()', function() {
}, true);
});
test('new Group([])', function() {
var group = new Group([]);
equals(function() {
return paper.project.activeLayer.children[0] == group;
}, true);
equals(function() {
return group.children.length;
}, 0);
});
test('new Group([item])', function() {
var path = new Path();
var group = new Group([path]);