MooTools: destroy () and events

When I .destroy()object Elementin MooTools, does. destroy()automatically internally calls element.removeEvents(), or I need to remember this. (I remove the elements from the DOM that previously called element.addEvent().)

+3
source share
2 answers

.destroy () in MooTools, version 1.2.4:

destroy: function(){
    Element.empty(this);
    Element.dispose(this);
    clean(this, true);
    return null;
}

The clean (item, save) function executes .removeEvents()if the browser needs it:

var clean = function(item, retain){
    ....
    if (item.clearAttributes){
        var clone = retain && item.cloneNode(false);
        item.clearAttributes();
        if (clone) item.mergeAttributes(clone);
    } else if (item.removeEvents){          
    ....
};

You must be safe by freeing items.

In addition, the credit for the entire code above is for MooTools, of course: http://mootools.net/

+2
source

, Mootools removeEvents(), destroy() .

( clean(), destroy()).

+2

Source: https://habr.com/ru/post/1730665/


All Articles