filter out elements no longer referenced in Ox.elements. dont set to Ox.Element, only pass on and oxid
This commit is contained in:
parent
d046574ac2
commit
853a402a7a
1 changed files with 31 additions and 16 deletions
|
@ -453,9 +453,11 @@
|
|||
() -> <[o]> Array of element objects
|
||||
@*/
|
||||
Ox.Element.prototype.childrenElements = function childrenElements() {
|
||||
return Ox.slice(this.children())
|
||||
.filter(Ox.isOxElement)
|
||||
.map(Ox.getOxElement);
|
||||
return Ox.compact(
|
||||
Ox.slice(this.children())
|
||||
.filter(Ox.isOxElement)
|
||||
.map(Ox.getOxElement)
|
||||
);
|
||||
};
|
||||
|
||||
/*@
|
||||
|
@ -492,9 +494,9 @@
|
|||
() -> <[o]> Array of element objects
|
||||
@*/
|
||||
Ox.Element.prototype.findElements = function findElements() {
|
||||
return Ox.slice(this.find('.OxElement'))
|
||||
.filter(Ox.isOxElement)
|
||||
.map(Ox.getOxElement);
|
||||
return Ox.compact(
|
||||
Ox.slice(this.find('.OxElement')).map(Ox.getOxElement)
|
||||
);
|
||||
};
|
||||
|
||||
/*@
|
||||
|
@ -545,7 +547,9 @@
|
|||
() -> <[o]> Array of element objects
|
||||
@*/
|
||||
Ox.Element.prototype.nextElements = function nextElements() {
|
||||
return this.nextAll().filter(Ox.isOxElement).map(Ox.getOxElement);
|
||||
return Ox.compact(
|
||||
this.nextAll().filter(Ox.isOxElement).map(Ox.getOxElement)
|
||||
);
|
||||
};
|
||||
|
||||
/*@
|
||||
|
@ -579,9 +583,11 @@
|
|||
() -> <[o]> Array of element objects
|
||||
@*/
|
||||
Ox.Element.prototype.parentElements = function parentElements() {
|
||||
return Ox.slice(this.parents())
|
||||
.filter(Ox.isOxElement)
|
||||
.map(Ox.getOxElement);
|
||||
return Ox.compact(
|
||||
Ox.slice(this.parents())
|
||||
.filter(Ox.isOxElement)
|
||||
.map(Ox.getOxElement)
|
||||
);
|
||||
};
|
||||
|
||||
/*@
|
||||
|
@ -610,7 +616,9 @@
|
|||
() -> <[o]> Array of element objects
|
||||
@*/
|
||||
Ox.Element.prototype.prevElements = function prevElements() {
|
||||
return this.prevAll().filter(Ox.isOxElement).map(Ox.getOxElement);
|
||||
return Ox.compact(
|
||||
this.prevAll().filter(Ox.isOxElement).map(Ox.getOxElement)
|
||||
);
|
||||
};
|
||||
|
||||
Ox.Element.prototype.remove = function remove() {
|
||||
|
@ -665,12 +673,17 @@
|
|||
($element) -> <o> This element object
|
||||
@*/
|
||||
Ox.Element.prototype.setElement = function setElement($element) {
|
||||
$element.addClass('OxElement').data({oxid: this.oxid});
|
||||
this.findElements().forEach(function($element) {
|
||||
$element.removeElement(false);
|
||||
});
|
||||
this.$element.replaceWith($element);
|
||||
this.$element = $element;
|
||||
if ($element.$element) { // $element is Ox.Element
|
||||
this.$element = $element.$element;
|
||||
this.$element.oxid = $element.oxid;
|
||||
} else { // $element is jQuery Element
|
||||
this.$element = $element;
|
||||
}
|
||||
this.$element.addClass('OxElement').data({oxid: this.oxid});
|
||||
this[0] = $element[0];
|
||||
return this;
|
||||
};
|
||||
|
@ -680,9 +693,11 @@
|
|||
() -> <[o]> Array of element objects
|
||||
@*/
|
||||
Ox.Element.prototype.siblingElements = function siblingElements() {
|
||||
return Ox.slice(this.siblings())
|
||||
.filter(Ox.isOxElement)
|
||||
.map(Ox.getOxElement);
|
||||
return Ox.compact(
|
||||
Ox.slice(this.siblings())
|
||||
.filter(Ox.isOxElement)
|
||||
.map(Ox.getOxElement)
|
||||
);
|
||||
};
|
||||
|
||||
Ox.Element.prototype.text = function text() {
|
||||
|
|
Loading…
Reference in a new issue