From 957cd6fb2a2b7b8cfe9ac6b3f2b3cc2bc8163449 Mon Sep 17 00:00:00 2001 From: John Resig Date: Thu, 27 Aug 2009 19:22:48 +0000 Subject: [PATCH] Tweaked the isXMLDoc iframe test case to test the document, not the body element (which doesn't exist in IE). Also made the isXMLDoc code handle cases where elem is null, undefined, etc. --- src/core.js | 2 +- test/unit/core.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core.js b/src/core.js index 890e9a2df..23b96442e 100644 --- a/src/core.js +++ b/src/core.js @@ -316,7 +316,7 @@ jQuery.extend({ isXMLDoc: function( elem ) { // documentElement is verified for cases where it doesn't yet exist // (such as loading iframes in IE - #4833) - return ((elem.ownerDocument || elem).documentElement || 0).nodeName !== "HTML"; + return ((elem ? elem.ownerDocument || elem : 0).documentElement || 0).nodeName !== "HTML"; }, // Evalulates a script in a global context diff --git a/test/unit/core.js b/test/unit/core.js index b6dc2064f..8decd4943 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -280,10 +280,10 @@ test("isXMLDoc - HTML", function() { document.body.appendChild( iframe ); try { - var body = jQuery(iframe).contents().find("body")[0]; - ok( !jQuery.isXMLDoc( body ), "Iframe body element" ); + var body = jQuery(iframe).contents()[0]; + ok( jQuery.isXMLDoc( body ), "Iframe body element" ); } catch(e){ - ok( false, "Iframe body element" ); + ok( false, "Iframe body element exception" ); } document.body.removeChild( iframe ); -- 2.39.5