Opened 11 years ago
Closed 11 years ago
#12901 closed bug (notabug)
isWindow returns true when it should be false
Reported by: | Owned by: | ||
---|---|---|---|
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; }
Change History (5)
comment:1 Changed 11 years ago by
comment:3 Changed 11 years ago by
Owner: | set to robinemarr@… |
---|---|
Status: | new → pending |
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?
comment:4 Changed 11 years ago by
Status: | pending → new |
---|
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
comment:5 Changed 11 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
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.
#12902 is a duplicate of this ticket.