Previously addChild was checking this: if(child.parent != undefined) but testing just for 'undefined' isn't enough, as the parent is set to 'null' in DisplayObject.js, so this condition fails and throws an error as it tries to removeChild from null.

This commit is contained in:
photonstorm 2013-12-23 03:18:18 +00:00
parent eb1d1b54fd
commit a180e1dd2d

View file

@ -37,9 +37,8 @@ PIXI.DisplayObjectContainer.prototype.constructor = PIXI.DisplayObjectContainer;
*/
PIXI.DisplayObjectContainer.prototype.addChild = function(child)
{
if(child.parent !== undefined)
if(child.parent && child.parent !== this)
{
//// COULD BE THIS???
child.parent.removeChild(child);
// return;