Ox.Element: update setElement; update and use findElements

This commit is contained in:
rlx 2014-09-24 11:57:02 +02:00
parent 0b5f8f9492
commit 02aeb4ea0c

View file

@ -466,7 +466,7 @@
};
Ox.Element.prototype.findElements = function findElements() {
return Ox.map(this.find('.OxElement'), Ox.getOxElement);
return Ox.slice(this.find('.OxElement')).map(Ox.getOxElement);
};
/*@
@ -570,9 +570,8 @@
Ox.Element.prototype.removeElement = function removeElement(includeChildren) {
if (includeChildren !== false) {
this.find('.OxElement').each(function() {
var $element = Ox.getElement(this);
$element && $element.removeElement(false);
this.findElements().forEach(function($element) {
$element.removeElement(false);
});
}
Ox.Focus.removeElement(this.oxid);
@ -602,10 +601,12 @@
@*/
Ox.Element.prototype.setElement = function setElement($element) {
$element.addClass('OxElement').data({oxid: this.oxid});
this.replaceWith($element);
this.findElements().forEach(function($element) {
$element.removeElement(false);
});
this.$element.replaceWith($element);
this.$element = $element;
this[0] = $element[0];
Ox.elements[this.oxid] = this;
return this;
};