fix clearPos and clickable/keyable check on removal. fixes #6.

This commit is contained in:
Christopher Jeffrey 2013-08-08 13:47:59 -05:00
parent 599b186614
commit 8c558dbf3f

View File

@ -109,20 +109,16 @@ Node.prototype.remove = function(element) {
var i = this.children.indexOf(element); var i = this.children.indexOf(element);
if (!~i) return; if (!~i) return;
if (this.type !== 'screen') { element.clearPos();
this.clearPos();
}
element.parent = null; element.parent = null;
this.children.splice(i, 1); this.children.splice(i, 1);
if (this.type !== 'screen') {
i = this.screen.clickable.indexOf(element); i = this.screen.clickable.indexOf(element);
if (~i) this.screen.clickable.splice(i, 1); if (~i) this.screen.clickable.splice(i, 1);
i = this.screen.keyable.indexOf(element); i = this.screen.keyable.indexOf(element);
if (~i) this.screen.keyable.splice(i, 1); if (~i) this.screen.keyable.splice(i, 1);
}
element.emit('reparent', null); element.emit('reparent', null);
this.emit('remove', element); this.emit('remove', element);