Skip to content

Commit 091cb93

Browse files
committed
Merge pull request phaserjs#1417 from pnstickne/wip-1410
Fixes phaserjs#1410 where newChild.parent could be set to undefined before use
2 parents 0cd0a5b + fe8c502 commit 091cb93

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/core/Group.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -692,24 +692,23 @@ Phaser.Group.prototype.replace = function (oldChild, newChild) {
692692

693693
if (index !== -1)
694694
{
695-
if (newChild.parent !== undefined)
695+
if (newChild.parent)
696696
{
697-
newChild.events.onRemovedFromGroup$dispatch(newChild, this);
698-
newChild.parent.removeChild(newChild);
699-
700697
if (newChild.parent instanceof Phaser.Group)
701698
{
702-
newChild.parent.updateZ();
699+
newChild.parent.remove(newChild);
700+
}
701+
else
702+
{
703+
newChild.parent.removeChild(newChild);
703704
}
704705
}
705706

706-
var temp = oldChild;
707-
708-
this.remove(temp);
707+
this.remove(oldChild);
709708

710709
this.addAt(newChild, index);
711710

712-
return temp;
711+
return oldChild;
713712
}
714713

715714
};

0 commit comments

Comments
 (0)