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 Array can fail #1037

Closed
mthurman opened this issue Aug 28, 2015 · 3 comments
Closed

instanceof Array can fail #1037

mthurman opened this issue Aug 28, 2015 · 3 comments

Comments

@mthurman
Copy link

I'm hacking on an Electron project which I'm trying to use elm for. In the electron code, one of my dependencies uses vm.runInNewContext which causes that code to have a different Array prototype which causes elm's instanceof checks to fail (see nodejs/node-v0.x-archive#1277).

Can elm use Arrays.isArray instead of instanceof checks?

It looks like it's probably just a matter of editing https://github.com/elm-lang/elm-compiler/blob/a9658ccb44cf3358991671b7abe02c4d87a31151/src/Generate/JavaScript/Port.hs#L87 and possibly adding a new helper. But I'm very new to elm (and don't have a great grounding in JS stuff anyway), so I figured I'd raise the issue before I sent a pull request.

@evancz
Copy link
Member

evancz commented Sep 28, 2015

How widely supported is the thing you are suggesting?

@rtfeldman, do you know anything about this?

@rtfeldman
Copy link
Member

It was introduced in ES5: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray

Unfortunately this is only one of many ways people can mess up the global execution environment in a way that could mess Elm up. Monkey patching is and always has been caveat emptor.

I think we should leave the current behavior as-is on this one.

@evancz
Copy link
Member

evancz commented Sep 29, 2015

Okay, I don't want to drop support for IE9 for this reason, and I suspect that's what we'd need to do here.

Thanks @rtfeldman!

@evancz evancz closed this as completed Sep 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants