-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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 with multiple windows/iframes #5886
Comments
Uh! Do you mind explaining a bit more what's happening? |
The problem with It's different for loaded scripts: A good explanation can be found here: http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/ |
And, isn't this the expected behaviour? |
Oh wait. So you're trying to use the library that you're loading inside an iframe from outside? |
Exactly. That's why instanceof Array isn't working as intended. |
That's a very strange use case. I'm not sure the whole library should get more unreadable because strange use cases... |
The use of e.g. If you have an arbitrary class It'd make writing abstractions over |
@mrdoob I agree that the particular usecase is uncommon, but the |
The consequences of not being so strict is (not forcing |
Not making more people mad is a good motivation. That said, I'm going to move away from this particular issue which is originally focused on var iframe = document.getElementsByTagName('iframe')[0]
window.Array !== iframe.contentWindow.Array However, shims for Array.isArray are readily available |
As the original issue mainly referred |
@mrdoob that sounds good to me |
I think we're at cross-purposes. If the issue would only reffer to Arrays, this solution would be fine, but it isn't. |
@andre161292 Doesn't your use case gets solved by just doing |
Fixed! |
Hey,
I experienced an issue with the raycaster, when using multiple windows/iframes.
In my case
objects instanceof Array === false
inintersectObjects
failed.Object.prototype.toString.call( objects ) !== '[object Array]'
works as expected.This effect is described here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
The text was updated successfully, but these errors were encountered: