Bug Tracker

Changes between Version 1 and Version 2 of Ticket #9425, comment 3


Ignore:
Timestamp:
May 25, 2011, 4:39:54 PM (12 years ago)
Author:
yahelc
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9425, comment 3

    v1 v2  
    1 Ticket should read:
    2 
    3 I know it's probably just an internal function, but I noticed this is how jQuery detects if an object is a window or not:
    4 {{{
    5 isWindow: function( obj ) {
    6                 return obj && typeof obj === "object" && "setInterval" in obj;
    7         }
    8 }}}
    9 But, that is easily broken by
    10 {{{
    11 var x = {"setInterval" : "foo" };
    12 }}}
    13 Wouldn't a better test be:
    14 {{{
    15 isWindow: function( obj ) {
    16                 return obj && typeof obj === "object"  && obj.window === window;
    17 }
    18 }}}
    19 
    20 since the window object contains itself infinite times (ie, window.window===window.window.window), whereas (if I'm not mistaken) a regular object wouldn't be able to met that condition.
     1(removed)