remove old prepend/append code.

This commit is contained in:
Christopher Jeffrey 2013-07-14 22:12:36 -05:00
parent aa951c640f
commit 4683b1d542
1 changed files with 8 additions and 66 deletions

View File

@ -55,64 +55,6 @@ Node.prototype.__proto__ = EventEmitter.prototype;
Node.prototype.type = 'node';
Node.prototype.prepend = function(element) {
// var old = element.parent;
element.detach();
element.parent = this;
if (this.type === 'screen' && !this.focused) {
this.focused = element;
}
if (!~this.children.indexOf(element)) {
this.children.unshift(element);
}
element.emit('reparent', this);
this.emit('adopt', element);
// if (!old) {
(function emit(el) {
el._detached = false;
el.emit('attach');
if (el.children) el.children.forEach(emit);
})(element);
// element.emitDescendants('attach', function(el) {
// el._detached = false;
// });
};
Node.prototype.append = function(element) {
// var old = element.parent;
element.detach();
element.parent = this;
if (this.type === 'screen' && !this.focused) {
this.focused = element;
}
if (!~this.children.indexOf(element)) {
this.children.push(element);
}
element.emit('reparent', this);
this.emit('adopt', element);
// if (!old) {
(function emit(el) {
el._detached = false;
el.emit('attach');
if (el.children) el.children.forEach(emit);
})(element);
// element.emitDescendants('attach', function(el) {
// el._detached = false;
// });
};
Node.prototype.insert = function(element, i) {
// var old = element.parent;
@ -148,6 +90,14 @@ Node.prototype.insert = function(element, i) {
// });
};
Node.prototype.prepend = function(element) {
this.insert(element, 0);
};
Node.prototype.append = function(element) {
this.insert(element, this.children.length);
};
Node.prototype.insertBefore = function(element, other) {
var i = this.children.indexOf(other);
if (~i) this.insert(element, i);
@ -158,14 +108,6 @@ Node.prototype.insertAfter = function(element, other) {
if (~i) this.insert(element, i + 1);
};
Node.prototype.prepend = function(element) {
this.insert(element, 0);
};
Node.prototype.append = function(element) {
this.insert(element, this.children.length);
};
Node.prototype.remove = function(element) {
element.parent = null;