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

@ibolmo
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()
@ibolmo
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();
@ibolmo ibolmo referenced this issue from a commit in ibolmo/mootools-core
@ibolmo ibolmo Fixes #2155.
Added Notes and See Also for `Elements.empty` to use `Element.destroy`
when appropriate.
23143c6
@ibolmo 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.