Bug Tracker

Changes between Initial Version and Version 1 of Ticket #9425, comment 1


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

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9425, comment 1

    initial v1  
    1 Ugh. Major fail. Can someone with privileges fix the code formatting? Sorry :(
     1Ticket should read:
     2
     3I 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{{{
     5isWindow: function( obj ) {
     6                return obj && typeof obj === "object" && "setInterval" in obj;
     7        }
     8}}}
     9But, that is easily broken by
     10{{{
     11var x = {"setInterval" : "foo" };
     12}}}
     13Wouldn't a better test be:
     14{{{
     15isWindow: function( obj ) {
     16                return obj && typeof obj === "object"  && obj.window === window;
     17}
     18}}}
     19
     20since 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.