diff --git a/src/item/Item.js b/src/item/Item.js index 1b3f5d0a..112d737c 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -2353,7 +2353,7 @@ new function() { // Injection scope for hit-test functions shared with project // Use the loop also to filter out wrong _type. for (var i = items.length - 1; i >= 0; i--) { var item = items[i]; - if (_proto && !(item instanceof _proto)) { + if (!item || _proto && !(item instanceof _proto)) { items.splice(i, 1); } else { // Notify parent of change. Don't notify item itself yet, diff --git a/test/tests/Group.js b/test/tests/Group.js index fdc72e6a..3c67df44 100644 --- a/test/tests/Group.js +++ b/test/tests/Group.js @@ -108,3 +108,21 @@ test('group.insertChildren(0, otherGroup.children)', function() { return group.children.length; }, 0); }); + +test('group.addChildren()', function() { + var group = new Group(); + var children = [new Path(), new Path()]; + group.addChildren(children); + equals(group.children.length, 2, + 'group.children.length after adding 2 children'); + group.removeChildren(); + equals(group.children.length, 0, + 'group.children.length after removing all children'); + children.splice(1, 0, null); + equals(children.length, 3, + 'children array length after inserting null at index 1'); + group.addChildren(children); + equals(group.children.length, 2, + 'calling group.addChildren() with an array with 3 entries, ' + + 'of which 2 are valid, group.children.length should be 2'); +});