Skip to main content

Bug Tracker

Side navigation

#12901 closed bug (notabug)

Opened November 15, 2012 05:05PM UTC

Closed November 16, 2012 01:22AM UTC

isWindow returns true when it should be false

Reported by: robinemarr@gmail.com Owned by: robinemarr@gmail.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description
var x = {};
x.window = x;

$.isWindow(x); // returns true

why not use:

isWindow = function (obj) {
    return obj && obj !== null && obj === window;
}

instead of:

isWindow = function (obj) {
    return obj && obj !== null && obj === obj.window;
  }
Attachments (0)
Change History (5)

Changed November 15, 2012 05:20PM UTC by dmethvin comment:1

#12902 is a duplicate of this ticket.

Changed November 15, 2012 05:21PM UTC by rwaldron comment:2

Those wouldn't match "window" from another frame.

Changed November 15, 2012 05:24PM UTC by dmethvin comment:3

owner: → robinemarr@gmail.com
status: newpending

Right, is *a* window. As for the bug, this is yet another case where we should not have exposed an internal utility method. But the test case seems pretty contrived anyway. Are you encountering this in real code as a result of calling $.isWindow() or is this manifesting in some other way?

Changed November 16, 2012 01:13AM UTC by robinemarr@gmail.com comment:4

status: pendingnew

Hi,

This wasn't found via any real world occurrence, one of my devs noticed it while studying jQuery in a learning exercise.

I agree the example is contrived and unlikely in a real world scenario, I just couldn't see why obj == window wouldn't work.

Cheers

Rob

Changed November 16, 2012 01:22AM UTC by dmethvin comment:5

resolution: → notabug
status: newclosed

Unfortunately, there's no simple test for seeing if something represents a window object that works from IE6 all the way to the latest browsers. We're good with what we have.