From 3cec5acbf11497d014ce2314a97366685f6b7ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Blais=20Masson?= Date: Wed, 2 Nov 2011 19:06:02 -0400 Subject: [PATCH 1/3] Less crude .isWindow() --- src/core.js | 3 +-- test/unit/core.js | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core.js b/src/core.js index 9e5a5523d5..f59abb11cb 100644 --- a/src/core.js +++ b/src/core.js @@ -478,9 +478,8 @@ jQuery.extend({ return jQuery.type(obj) === "array"; }, - // A crude way of determining if an object is a window isWindow: function( obj ) { - return obj && typeof obj === "object" && "setInterval" in obj; + return obj != null && obj === obj.window; }, isNumeric: function( obj ) { diff --git a/test/unit/core.js b/test/unit/core.js index 0756e7947b..63d911029f 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -552,9 +552,10 @@ test("isXMLDoc - XML", function() { } test("isWindow", function() { - expect( 12 ); + expect( 14 ); ok( jQuery.isWindow(window), "window" ); + ok( jQuery.isWindow(document.getElementsByTagName('iframe')[0].contentWindow), "iframe.contentWindow" ); ok( !jQuery.isWindow(), "empty" ); ok( !jQuery.isWindow(null), "null" ); ok( !jQuery.isWindow(undefined), "undefined" ); @@ -564,8 +565,7 @@ test("isWindow", function() { ok( !jQuery.isWindow(1), "number" ); ok( !jQuery.isWindow(true), "boolean" ); ok( !jQuery.isWindow({}), "object" ); - // HMMM - // ok( !jQuery.isWindow({ setInterval: function(){} }), "fake window" ); + ok( !jQuery.isWindow({ setInterval: function(){} }), "fake window" ); ok( !jQuery.isWindow(/window/), "regexp" ); ok( !jQuery.isWindow(function(){}), "function" ); }); From 68d64a12661b4b60758f71d7206c73fd6cf57904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Blais=20Masson?= Date: Sun, 6 Nov 2011 16:09:53 -0500 Subject: [PATCH 2/3] Double quotes --- test/unit/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/core.js b/test/unit/core.js index 63d911029f..a9ef5ca635 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -555,7 +555,7 @@ test("isWindow", function() { expect( 14 ); ok( jQuery.isWindow(window), "window" ); - ok( jQuery.isWindow(document.getElementsByTagName('iframe')[0].contentWindow), "iframe.contentWindow" ); + ok( jQuery.isWindow(document.getElementsByTagName("iframe")[0].contentWindow), "iframe.contentWindow" ); ok( !jQuery.isWindow(), "empty" ); ok( !jQuery.isWindow(null), "null" ); ok( !jQuery.isWindow(undefined), "undefined" ); From 89246aaaba68f4e5b235ec0b7b5dcc2616d4c787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Blais=20Masson?= Date: Sun, 6 Nov 2011 16:23:09 -0500 Subject: [PATCH 3/3] Fix jQuery.isWindow for IE6-8 --- src/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index f59abb11cb..84564a4f01 100644 --- a/src/core.js +++ b/src/core.js @@ -479,7 +479,7 @@ jQuery.extend({ }, isWindow: function( obj ) { - return obj != null && obj === obj.window; + return obj != null && obj == obj.window; }, isNumeric: function( obj ) {