From bda7c71fcbc14295423ee408356105f87822e2ae Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 6 Nov 2012 18:07:11 +0100 Subject: [PATCH] Fix problem when calling new Group([]). --- src/item/Group.js | 2 +- test/tests/Group.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/item/Group.js b/src/item/Group.js index 3de37b1b..7d2922b8 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -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) { diff --git a/test/tests/Group.js b/test/tests/Group.js index 5dc66c0f..c420b957 100644 --- a/test/tests/Group.js +++ b/test/tests/Group.js @@ -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]);