JSFiddle - React, Tailwind, and code Playground
HTML
<div class="foo">foo</div>
JavaScript
(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();