File tree 2 files changed +4
-5
lines changed
2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -476,9 +476,8 @@ jQuery.extend({
476
476
return jQuery . type ( obj ) === "array" ;
477
477
} ,
478
478
479
- // A crude way of determining if an object is a window
480
479
isWindow : function ( obj ) {
481
- return obj && typeof obj === "object" && "setInterval" in obj ;
480
+ return obj != null && obj == obj . window ;
482
481
} ,
483
482
484
483
isNumeric : function ( obj ) {
Original file line number Diff line number Diff line change @@ -558,9 +558,10 @@ test("isXMLDoc - XML", function() {
558
558
}
559
559
560
560
test ( "isWindow" , function ( ) {
561
- expect ( 12 ) ;
561
+ expect ( 14 ) ;
562
562
563
563
ok ( jQuery . isWindow ( window ) , "window" ) ;
564
+ ok ( jQuery . isWindow ( document . getElementsByTagName ( "iframe" ) [ 0 ] . contentWindow ) , "iframe.contentWindow" ) ;
564
565
ok ( ! jQuery . isWindow ( ) , "empty" ) ;
565
566
ok ( ! jQuery . isWindow ( null ) , "null" ) ;
566
567
ok ( ! jQuery . isWindow ( undefined ) , "undefined" ) ;
@@ -570,8 +571,7 @@ test("isWindow", function() {
570
571
ok ( ! jQuery . isWindow ( 1 ) , "number" ) ;
571
572
ok ( ! jQuery . isWindow ( true ) , "boolean" ) ;
572
573
ok ( ! jQuery . isWindow ( { } ) , "object" ) ;
573
- // HMMM
574
- // ok( !jQuery.isWindow({ setInterval: function(){} }), "fake window" );
574
+ ok ( ! jQuery . isWindow ( { setInterval : function ( ) { } } ) , "fake window" ) ;
575
575
ok ( ! jQuery . isWindow ( / w i n d o w / ) , "regexp" ) ;
576
576
ok ( ! jQuery . isWindow ( function ( ) { } ) , "function" ) ;
577
577
} ) ;
You can’t perform that action at this time.
0 commit comments