SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    "delete" Node Properties in IE6

    I've been going over Quirksmode's addEvent contest lately, in particular John Resig's entry. The event listener is attached to the element with the following lines:

    Code javascript:
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}

    This fixes the "this" problem. But a lot of people pointed out that this will leak memory if not removed like so (when the event listener is removed, or when the page is unloaded):

    Code javascript:
    delete obj['e'+type+fn];
    delete obj[type+fn];

    However, I tried adding the deletes, and I got an error in IE6. On further investigation, it appeared that IE6 won't let you use the delete operator on an element node. Is there another way to free up this memory? This is the best I can do, but some comments suggested it doesn't really stop the leaks:

    Code javascript:
    obj['e'+type+fn] = obj[type+fn] = null;

    Any suggestions?

  2. #2
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,011
    Mentioned
    56 Post(s)
    Tagged
    0 Thread(s)
    Don't use IE 6?

    Unless this is a corporate intranet project I wouldn't worry about saving memory as long as the rest of the code works. Ultimately this is the sort of thing the browser's garbage collection should handle. I mean, honestly, IE 6 users deserve the degraded browsing experience their browser gives them. Attempting to fix stuff like this is akin to putting lipstick on a pig.

  3. #3
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That's pretty much what I figured. Well, not the "lipstick on a pig" part, but the whole, "if you're not using a browser that has addEventListener, then you'll just have to put up a worse experience" perspective.

  4. #4
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,011
    Mentioned
    56 Post(s)
    Tagged
    0 Thread(s)
    Heh heh. I applaud you for trying. I remember my fights with IE 6.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •