Prototype: IE Leak-Safe Element#remove
February 21st, 2008
Thought this might help someone out. This adapts Prototype's Element#remove method to conditionally use a "leak-safe" method of removal outlined in this post on the MSDN forums.
/*
Adapted for Prototype based on:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2847218&SiteID=1
*/
Element.removeWithoutLeakProtection = Element.Methods.remove;
Element.addMethods({
discard: function(element){
element = $(element);
var garbageBin = $('IELeakGarbageBin') || document.body.appendChild(
new Element('div', { id:'IELeakGarbageBin', style:'display:none;' })
);
garbageBin.appendChild(element);
garbageBin.innerHTML = '';
return element;
},
remove: function(element){
if( Prototype.Browser.IE ){
return Element.discard(element);
} else {
return Element.removeWithoutLeakProtection(element);
}
}
});
Sorry, comments are closed for this article.