On Wed, Dec 15, 2010 at 5:30 PM, Peter Foti <[email protected]> wrote: > On Wed, Dec 15, 2010 at 11:14 AM, Asen Bozhilov <[email protected]> > wrote: >> >> Peter Foti : >> >> > function addEvent( obj, type, fn ) { >> > if ( obj.attachEvent ) { >> > obj['e'+type+fn] = fn; >> > obj[type+fn] = function(){obj['e'+type+fn]( window.event );} >> > obj.attachEvent( 'on'+type, obj[type+fn] ); >> > } >> >> This is perfectly example of how you can setup circular reference >> pattern, which cause memory leak in older IE. > > Those leaks were fixed 3 and a half years ago. > http://support.microsoft.com/kb/929874/ > But yes, for the severe minority who are still using IE6 and never bothered > to get the update, this may leak memory for them. As I said, there are many > roll-your own approaches out there, I just picked one at random. :) > -Peter Foti >
You picked the wrong example. Using the "type" and the string representation of the function "fn" as index is a no-no ! Doing that on the object itself make it still worst. I don't want to name the guy that initially wrote this but I can at least say this was the worst event helper implementation ever. -- Diego > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
