Skip to content

Commit

Permalink
Test for window inference. Fixes #10080
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Aug 18, 2011
1 parent f44d5e1 commit 93beee8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ jQuery.extend({
// 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
// Ensure that this id actually exists in `cache` #10080
if ( cache[ id ] && ( jQuery.support.deleteExpando || cache != window ) ) {
// Ensure that `cache` is not a window object #10080
if ( jQuery.support.deleteExpando || !cache.setInterval ) {

This comment has been minimized.

Copy link
@pomeh

pomeh Nov 4, 2011

Why not using jQuery.isWindow method here ?

This comment has been minimized.

Copy link
@rwaldron

rwaldron Nov 4, 2011

Author Member

Because there is no need to add a function call to the stack

delete cache[ id ];
} else {
cache[ id ] = null;
Expand Down
13 changes: 13 additions & 0 deletions test/unit/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,16 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert

});
});

// Test originally by Moschel
test("Triggering the removeData should not throw exceptions. (#10080)", function() {
expect(1);
stop();
var frame = jQuery("#loadediframe");
jQuery(frame[0].contentWindow).bind("unload", function() {
ok(true, "called unload");
start();
});
// change the url to trigger unload
frame.attr("src", "data/iframe.html?param=true");
});

0 comments on commit 93beee8

Please sign in to comment.