Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Object doesn't support property of method 'forEach' - IE 11 #26

Closed
blandfried-magellan opened this issue Jul 24, 2018 · 5 comments
Closed

Comments

@blandfried-magellan
Copy link

blandfried-magellan commented Jul 24, 2018

  1. What version of RJEA are you using (react-json-editor-ajrm version)?
    • 2.4.9
  2. What operating system and processor architecture are you using?
    • macOS High Sierra
  3. What did you do?
    • Tried to edit JSON in Internet Explorer 11
  4. What did you expect to see?
    • The onChange function to fire correctly with changed JSON
  5. What did you see instead?
    • Error in console about forEach not being supported

I've seen this before where the project isn't getting transpiled correctly with polyfills.

screen shot 2018-07-24 at 11 48 26 am

@AndrewRedican AndrewRedican self-assigned this Jul 24, 2018
@AndrewRedican AndrewRedican added bug high priority will add or fix within three days labels Jul 24, 2018
@AndrewRedican
Copy link
Owner

@blandfried-magellan, good catch. I'll submit a fix in the next few days.

@blandfried-magellan
Copy link
Author

I think you want to use transformRuntime plugin. Had same issue with below and that's how they fixed it.

okta/okta-signin-widget@3b58e80

@AndrewRedican AndrewRedican removed the high priority will add or fix within three days label Jul 29, 2018
@AndrewRedican AndrewRedican added this to the Stability milestone Jul 29, 2018
@AndrewRedican AndrewRedican removed their assignment Aug 27, 2018
@SachsKaylee
Copy link
Collaborator

I did some more readup on this today since this issue still persists:

We are already using @babel/transform-runtime which was suggested above in our current build setup. This plugin polyfills ES6 features to ES5.

The reason that it still isn't working, is that the transform-runtime plugin does not polyfill instance methods (such as forEach, map, reduce, ...), due to the dynamic nature of JavaScript(It cannot possibly know if myVar.forEach refers to the built-in array method, or if we simply have a custom object with a forEach property on it).
See this comment and/or post for details: w3ctag/polyfills#6 (comment)

So what is the solution to this? Honestly, I'm not certain.

We could go the route the mentioned okta-signin-widget took and add another polyfill dependency to this project. The babel-polyfill library is to my understanding though rather large and injects itself into the global scope since it includes every polyfill possibly imaginable to ensure that all instance methods exists.

We could write our own functions to emulate the functionality of forEach, etc... But I'm not sure of how maintainable it is to manually check browser support every time you use a function, and possibly re-write your own version of it.

We could no longer polyfill at all and require the user to do it, but this will make this library rather unintuitive to use and probably create a large amount of issues.

Any suggestions? 😃

@AndrewRedican
Copy link
Owner

Thanks for taking your time to look at this.

How do you feel about just sticking to plain old for loops?

It sounds like the easiest and quickest solution. That I can think of using for loops of the top of my head will only add one or two lines of code on each loop.

@SachsKaylee
Copy link
Collaborator

How do you feel about just sticking to plain old for loops?

Yeah, I think that's the easiest, least headache inducing option for now.

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

No branches or pull requests

3 participants