mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Fix Item#insertChildren() error when passing null for some children.
Relates to #1036
This commit is contained in:
parent
693898a5b1
commit
742401a0e1
2 changed files with 19 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue