I'm using babel 6.7 to build a single page React.js web app. I've tried to include all the relevant polyfills e.g. babel-polyfill to make it compatible with ES5 browsers. Even still, I get a javascript error every now and again like this
Object doesn't support property or method 'jscomp_symbol_iterator0'
mostly from users on windows 7 & 8.1 running IE10+.
I'm assuming it's something to do with js Symbol.iterator not being supported. Is there a way I can polyfill this for older browsers?
Thanks!
In my case the error:
Object doesn't support property or method 'Symbol.iterator'
Pointed to a specific line related to the ES6 syntax of a for
loop. I.e., I had this:
for(let el of document.getElementsByClassName('especial-els')) { /* ... */ }
And all I needed to do to fix it was changing this loop to an "old-style" loop:
let especialEls = document.getElementsByClassName('especial-els');
for(let i = specialEls.length - 1; i >= 0; i--) { /* ... */ }
This error only occurred in the Edge browser (not in Chrome and not in Firefox) and particularly only in this for(let i of iterator)
loop (I have other loops of this kind iterating over arrays and the error does not show up). My guess is that document.getElementsByClassName()
returns a "especial" iterator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With