Bug Tracker

Opened 15 years ago

Closed 15 years ago

#3055 closed bug (duplicate)

IE leak prevention causes content loss

Reported by: yaakov Owned by:
Priority: minor Milestone: 1.3
Component: event Version: 1.2.6
Keywords: IE memory leak; back button Cc:
Blocked by: Blocking:

Description

Short summary

  • Interactively (by mouse clicks) add content to a page (with .after(content)).
  • Go to another page (e.g. by following a link).
  • Hit the back button to come back to the interactive page.

==> Note: The dynamic changes are lost!

This bug is caused by code that prevents memory leaks in IE: when I remove three lines from jQuery.js, the bug disappears.

Example

Note: all example code is attached to this bug report. But you can also look at the live examples on the web.

  • I have tested this with Firefox 3. I don't know whether it shows up with other browsers.
  • open this page: http://www.yaakovnet.net/jQueryBug1/bug.html
  • as instructed, click on the text "Click here!"
    • ==> a note (click) should appear. You can click several times.
  • now follow the link on the page .... and come back by using your back button.
  • Note: the dynamically added (click) notes are gone! This is the bug!

Localizing the problem

The bug is caused by the following lines in jquery.js:

  // Prevent memory leaks in IE
  // And prevent errors on refresh with events like mouseover in
     other browsers
  // Window isn't included so as not to unbind existing unload
     events

  jQuery(window).bind("unload", function() {
    jQuery("*").add(document).unbind();
  });

I created a version jquery-modified.js where the last three lines are commented out. As you can see, using this modified version fixes our problem:

Fixing the problem

Of course, disabling the three lines may cause memory leaks in IE.

  • Maybe the call jQuery("*").add(document).unbind() is too general? Leaving some selected events bound may solve our problem without introducing (too many) IE leaks.
  • Alternatively --- we should all switch to Firefox.

Attachments (4)

bug.html (435 bytes) - added by yaakov 15 years ago.
html for the bug
fixed.html (416 bytes) - added by yaakov 15 years ago.
html using jquery-modified.js --- show test without the bug
jquery-modified.js (97.9 KB) - added by yaakov 15 years ago.
jquery.js with three lines disabled --- this removes the bug.
go-back.html (71 bytes) - added by yaakov 15 years ago.
a plain html page referenced by the html examples

Download all attachments as: .zip

Change History (6)

Changed 15 years ago by yaakov

Attachment: bug.html added

html for the bug

Changed 15 years ago by yaakov

Attachment: fixed.html added

html using jquery-modified.js --- show test without the bug

Changed 15 years ago by yaakov

Attachment: jquery-modified.js added

jquery.js with three lines disabled --- this removes the bug.

Changed 15 years ago by yaakov

Attachment: go-back.html added

a plain html page referenced by the html examples

comment:1 Changed 15 years ago by flesler

Component: coreevent
Priority: majorminor

This removal won't be taken out. It's very common to remove all the bindings on window unload, so it's expected that a back action will face these problems.

Still, I'll leave this open for now.

comment:2 Changed 15 years ago by flesler

Resolution: duplicate
Status: newclosed

1.3 will do this much faster, that should be enough. If the problem persist, do reopen or file a new ticket.

Note: See TracTickets for help on using tickets.