admin管理员组文章数量:1415476
When I .destroy()
an Element
object in MooTools, does .destroy()
automatically internally call element.removeEvents()
, or do I need to keep this in mind. (I'm removing elements from the DOM that have previously had element.addEvent()
called.)
When I .destroy()
an Element
object in MooTools, does .destroy()
automatically internally call element.removeEvents()
, or do I need to keep this in mind. (I'm removing elements from the DOM that have previously had element.addEvent()
called.)
2 Answers
Reset to default 3.destroy() in MooTools, version 1.2.4:
destroy: function(){
Element.empty(this);
Element.dispose(this);
clean(this, true);
return null;
}
The clean(item, retain) function does .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 should be safe, it's emptying out the elements.
Also, credit for all code above to MooTools of course: http://mootools/
Yes, Mootools will call removeEvents()
when you call destroy()
on an element.
(The current implementation does this in a function called clean()
that is called from destroy()
).
本文标签: javascriptMooTools destroy() and eventsStack Overflow
版权声明:本文标题:javascript - MooTools: destroy() and events - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745188872a2646813.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论