On Wed, Dec 15, 2010 at 1:29 PM, Diego Perini <[email protected]>wrote:

> 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.
>

Yeah, I just grabbed that particular example without even looking at the
code.  It was from a very well know and well respected name in the
JavaScript world, so I just took for granted that it would be of high
quality.  My bad for not looking more closely. :)

Peter

-- 
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]

Reply via email to