From f44d5e1e815ce63b58264b2f9a764c0b03101cfc Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 17 Aug 2011 17:49:09 -0400 Subject: Ensure cache[id] exists before attempting to delete it. Fixes #10080 --- src/data.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/data.js b/src/data.js index 4f87a3550..936cd76b8 100644 --- a/src/data.js +++ b/src/data.js @@ -191,7 +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 - if ( jQuery.support.deleteExpando || cache != window ) { + // Ensure that this id actually exists in `cache` #10080 + if ( cache[ id ] && ( jQuery.support.deleteExpando || cache != window ) ) { delete cache[ id ]; } else { cache[ id ] = null; -- cgit v1.2.3 From 93beee8ac0c035285ffab63a5c08cf1ac9cf2b2f Mon Sep 17 00:00:00 2001 From: rwldrn Date: Thu, 18 Aug 2011 10:17:12 -0400 Subject: Test for window inference. Fixes #10080 --- src/data.js | 4 ++-- test/unit/data.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/data.js b/src/data.js index 936cd76b8..4914971ea 100644 --- a/src/data.js +++ b/src/data.js @@ -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 ) { delete cache[ id ]; } else { cache[ id ] = null; diff --git a/test/unit/data.js b/test/unit/data.js index 4e21f563e..06c6c2d57 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -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"); +}); -- cgit v1.2.3