Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instanceof function on objects returned from jsdom window #424

Closed
ghost opened this issue Mar 22, 2012 · 4 comments
Closed

instanceof function on objects returned from jsdom window #424

ghost opened this issue Mar 22, 2012 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 22, 2012

I don`t know so much if this is a bug. It is one of those things that makes sense the way it works but introduces some subtle issues into ones application.

When working with jQuery like the example suggests this pops up so it is worth noting in the docs. Objects jQuery return are of the type window.Array window.Object etc and not part of the Node prototype. For example window.$.map returns something that is a window.Array and not an actual Array.

Subtle difference but it could be a while before you notice these things running around you application are not actually Arrays, Objects etc.

I bet this pops up a million more places. I have been hacking at this for a while and it even caught me off guard. Again not so much a bug just a little fact that makes bugs.

:)

@domenic
Copy link
Member

domenic commented Oct 5, 2012

So if I am understanding this correctly, you have a jsdom window, but window.Array is undefined, so

window.$("div") instanceof window.Object

is false? Whereas

window.$("div") instanceof global.Object

is true?

If this is the exact problem, it should be easy to fix, by just hanging a few of the more obvious globals off of window.

@domenic domenic mentioned this issue Dec 3, 2012
@domenic
Copy link
Member

domenic commented Jul 21, 2013

Upon further inspection, the current behavior is correct: we can't let changes to the Node globals interfere with the changes in a given window, or even worse, let changes in one window interfere with changes in another window (which would be the case if they all shared the Node globals).

@domenic domenic closed this as completed Jul 21, 2013
@NStal
Copy link

NStal commented Jul 27, 2013

It that means "Set User-Agent" won't be fixed?

@domenic
Copy link
Member

domenic commented Jul 27, 2013

@NStal I have no idea what you are asking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants