Skip to main content

Bug Tracker

Side navigation

#10080 closed bug (fixed)

Opened August 17, 2011 08:47PM UTC

Closed August 25, 2011 07:18PM UTC

Last modified September 01, 2011 05:02PM UTC

unload from frame's window breaks in IE8

Reported by: Owned by: rwaldron
Priority: low Milestone: 1.6.3
Component: data Version: git
Keywords: Cc:
Blocked by: Blocking:

If you have an iframe in the same domain and try to bind to unload:


This works in all browsers except IE8.

The problem is when you bind to unload, it uses the "one" method, so after unload, it unbinds itself and calls jquery.removeData, which has this:

// Browsers that fail expando deletion also refuse to delete expandos on
// the window, but it will allow it on all other JS objects; other browsers
// don't care
if ( || cache != window ) {
  delete cache[ id ];
} else {
  cache[ id ] = null;

That first if is true for IE8 and below I believe. Cache isn't the current window in this case, its another frame's window object, so delete cache[id] throws an error, and the unload event handler isn't reached

The fix is to check if cache is any window, not just the current window

Attachments (0)
Change History (15)

Changed August 17, 2011 08:49PM UTC by anonymous comment:1

I should say the error thrown is "Object doesn't support this action" and at least in 1.6.2 its on delete cache[id].

The error prevents the event handler from being called at all.

Changed August 17, 2011 09:02PM UTC by rwaldron comment:2

component: unfileddata
milestone: None1.6.3
priority: undecidedlow
resolution: → duplicate
status: newclosed

Changed August 17, 2011 09:02PM UTC by rwaldron comment:3

Duplicate of #8235.

Changed August 17, 2011 09:12PM UTC by comment:4

I don't think those 2 bugs are duplicates. In 8235, they said:

cache[ id ][ internalKey ] is checked without ensuring that cache[ id ] exists.

In the error I'm describing, the problem is

if ( || cache != window )

is true if cache is another frame's window, but delete cache[id] breaks. That if statement should check if cache is ANY window, not just the current one. Those are not the same cases.

Changed August 17, 2011 09:13PM UTC by comment:5

That code sample should show:

if ( || cache != window )

Changed August 17, 2011 09:44PM UTC by rwaldron comment:6

resolution: duplicate
status: closedreopened

Or you could simply ensure that cache[ id ] actually exists...

Which is the same issue.

Changed August 17, 2011 09:44PM UTC by rwaldron comment:7

Changed August 18, 2011 02:33AM UTC by dmethvin comment:8

Is this a result of not having a test case for #8235? We fixed that problem without knowing the cause.

Changed August 18, 2011 06:38AM UTC by comment:9

That pull request doesn't actually address the issue I'm talking about. The core issue is that cache can be any window object.

I made a pull request with a test that currently breaks in IE8 and a fix.

Changed August 18, 2011 01:02PM UTC by rwaldron comment:10

@dmethvin, no they are actually unrelated.

Changed August 18, 2011 02:21PM UTC by rwaldron comment:11

Using jQuery.isWindow will be significantly slower and all calls to removeData will be affected, see:

I've updated my branch to test for a window inference and have included your test with credit to you.

Changed August 18, 2011 02:30PM UTC by dmethvin comment:12

Yes .isWindow() is slower but look at the numbers. Even the "slow" path can run almost 2 *million* times a second. It's not likely the .removeData() path is critical enough that the difference matters.

Changed August 25, 2011 02:43PM UTC by dmethvin comment:13

owner: → rwaldron
status: reopenedassigned

Changed August 25, 2011 07:18PM UTC by Dave Methvin comment:14

resolution: → fixed
status: assignedclosed

Merge pull request #468 from rwldrn/10080

Fixes #10080. Test cache for window inference.

Changeset: f4811bfb04206b9d9c120001603eadb1b529c271

Changed September 01, 2011 05:02PM UTC by dmethvin comment:15

#8870 is a duplicate of this ticket.