Element.empty does not destroy #2155

Closed
ibolmo opened this Issue Dec 3, 2011 · 1 comment

Projects

None yet

1 participant

@ibolmo
Member
ibolmo commented Dec 3, 2011

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
Member
ibolmo commented Dec 10, 2011

@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 added a commit to ibolmo/mootools-core that referenced this issue Dec 20, 2011
@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 Jan 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment