Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Element.empty does not destroy #2155

Closed
ibolmo opened this Issue · 1 comment

1 participant

Olmo Maldonado
Olmo Maldonado
Owner

As of 1.4.2:

    empty: function(){
        while (this.length) delete this[--this.length];
        return this;
    }.protect()

Why aren't we:

    empty: function(){
        while (this.length) this[--this.length].destroy();
        return this;
    }.protect()
Olmo Maldonado
Owner

@cpojer @arian I've been thinking about this. Technically empty in Array.js doesn't do anything to the objects inside, it just removes them from the array. Which is what's currently done in 1.4.2. Perhaps just a special note in the docs will suffice to express a best practice:

Note:

Elements.empty does not destroy the elements inside. As best practice, always destroy your elements if they're no longer in use. For example:

$$('div').destroy().empty();
Olmo Maldonado ibolmo referenced this issue from a commit in ibolmo/mootools-core
Olmo Maldonado ibolmo Fixes #2155.
Added Notes and See Also for `Elements.empty` to use `Element.destroy`
when appropriate.
23143c6
Olmo Maldonado ibolmo closed this in bf35c9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.