whereas you can do it, it’s impractical.
first - destroy- the event fills the fire with the context of the element being destroyed, at this point during the cb event it will be deleted and GCd, possibly.
second, IE6,7,8, , , $/document.id - , , , DOM.
-, , , el.parentNode.innerHTML = '' raw js/ . , 2 .
http://jsfiddle.net/5YYyb/1/
(function(){
var destroy = Element.prototype.destroy,
dispose = Element.prototype.dispose;
[Element, Elements].invoke('implement', {
destroy: function(){
this.fireEvent('destroy');
return destroy.apply(this, arguments);
},
dispose: function(){
this.fireEvent('dispose');
return dispose.apply(this, arguments);
}
});
}());
var foo = document.getElement('.foo');
foo.addEvents({
dispose: function(){
alert('we are not in the dom now');
}
});
foo.dispose();