Skip to content
This repository

Element.empty does not destroy #2155

Closed
ibolmo opened this Issue December 03, 2011 · 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 December 20, 2011
Olmo Maldonado Fixes #2155.
Added Notes and See Also for `Elements.empty` to use `Element.destroy`
when appropriate.
23143c6
Olmo Maldonado ibolmo closed this in bf35c9f January 09, 2012
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.