-
Notifications
You must be signed in to change notification settings - Fork 127
Object doesn't support property of method 'forEach' - IE 11 #26
Comments
@blandfried-magellan, good catch. I'll submit a fix in the next few days. |
I think you want to use transformRuntime plugin. Had same issue with below and that's how they fixed it. |
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). 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? 😃 |
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. |
Yeah, I think that's the easiest, least headache inducing option for now. |
I've seen this before where the project isn't getting transpiled correctly with polyfills.
The text was updated successfully, but these errors were encountered: