Hi,
I tried to use the polyfill with IE 11 & when I use a for-of loop I have an "object expected" error which seems to be related to the Symbol.iterator polyfill.
I've read that your polyfill assumes that Symbol is native. Do you plan to fix this?
Is this for ... of over a nodelist or similar DOM collection? They are not supported yet, but hopefully will be within the next few weeks
Possibly fixed in https://github.com/Financial-Times/polyfill-service/pull/798
I have the problem with this code for instance.
ps.: I don't want to use for-in :)
That's a syntax issue I believe. Ie11 doesn't look like it supports this
syntax - https://msdn.microsoft.com/en-us/library/dn858238(v=vs.94).aspx
On 3 Aug 2016 6:04 p.m., "shiftie" [email protected] wrote:
I have the problem with this code
https://gist.github.com/shiftie/e501556c7dbf9e22649b35ba3a318f4f for
instance.ps.: I don't want to use for-in :)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Financial-Times/polyfill-service/issues/792#issuecomment-237276555,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABfxa2LoyEKrlLMcpZcL_BPHvWhPgijjks5qcMS3gaJpZM4JZdRm
.
Why is that? Isn't polyfill supposed to make it work? :)
For new syntax introduced in ES6 (e.g. const, for ... of) you still need to preprocess your code with something like Babel as in older browsers it will throw a parse error. Polyfill.io is limited to providing new APIs introduced in ES6/the web platform which are still valid ES5 syntax e.g. Promise, Set, Map, Symbol*, Symbol.iterator.
In the case of for .. of, despite still needing to babelify your code, there is still an advantage in using polyfill.io as it means you can use the {polyfill: false} option in the babel-runtime plugin, which can greatly reduce the size of your javascript bundle.
*although Symbol - because it introduces new values to the typeof operator - is a more difficult case
The code I'm running is already processed by Babel (replaces const, let, import....) passed to Browserify & then handled by the browser. Here is the Babelified code of the former loop.
This code still throws Object expected in IE11 when run in console on a page that has the following script attached: https://cdn.polyfill.io/v2/polyfill.js?ua=ie%2F11
I am experiencing same issues. Running the code that is transpiled by the Babel and Symbol.iterator is missing from array objects. After explicitly requesting it with https://cdn.polyfill.io/v2/polyfill.js=features=Array.prototype.@@iterator it works, but then I have to either do another request for remaining features or list them all there. Shouldn't Array.prototype.@@iterator be part of default set since Symbol.iterator is there?
Similar issue goes with Set as well, no Symbol.iterator present, but in this case there isn't really a polyfill that would fix it. Although it strange. Now I see that Set polyfill already has iterator included, but after loading default polyfill for IE11 and running Object.getOwnPropertySymbols(new Set()) I am getting empty array.
@FredyC - It sounds like you want the default set plus the es6 set and possibly even the es5 set. You can request the default set plus other features in one request, here is an example which asks for the default,es5 and es6 set -- https://polyfill.io/v2/polyfill.js=features=default,es5,es6.
It also looks like we have not added the es6 alias to the configuration for Array.prototype.@@iterator polyfill.
With regards to the Set issue you also mentioned. Our polyfill does include a method for Set.prototype[Symbol.iterator]. Would you be able to create a separate issue for this bug with some code to replicate it, preferably a jsbin.com page.
Thanks for reporting these issues.
@JakeChampion I guess I have to be explicit about Array.prototype.@@iterator since it's not included in any set. Although it doesn't make much sense why default set should have Symbol.iterator but not this one. Thanks anyway for features=default tip, I did not realize it's possible like that :)
I will try to have a closer look into Set issue tomorrow.
The default set includes the well-known symbol Symbol.iterator as it is a dependency of Set and Map which are included in the default set.
I haven't added anything to the default set as of yet, I'm not sure how we decide what gets added. I imagine an RFC to add a polyfill to the default set would be a good approach to take. Is there anything else you think should be added to the default set?
By having Symbol.iterator it seems to be logically implied it will be also used in appropriate places, eg on Array. Doesn't make much sense why default polyfill should include it in Set/Map but not arrays. Just my 2 cents...
Problem with the Set hasn't occurred today for some reason.
Set was added a while before Array.prototype.@@iterator was added.
@FredyC are you able to confirm that your issue using for ( of ) {} syntax compiled to ES5 syntax works when you include our Array.prototype.@@iterator polyfill? If that is the case I believe we can close this issue. We can also raise a new issue about updating the default set.
It's been a couple of weeks. Let's close this and @FredyC can reopen if he has further comment
I was having a similar issue and the suggested polyfill.io url didn't work for me until I realized there was a typo. It shouldnt be ...=features, but ...?features like this:
https://polyfill.io/v2/polyfill.js?features=default,es5,es6
--or--
https://cdn.polyfill.io/v2/polyfill.min.js?features=default,es5,es6
I had the same issue with the absence of NodeList.prototype.@@iterator polyfill. After this incident, I began to include all @@iterator polyfills in my projects. I was surprised why they are not included in the es6 set.
+1 to @BroFox86's comment - we were also surprised by Array.prototype.@@iterator missing even though Symbol.iterator was present and it gave us some difficulty in debugging the Babel transpiled for...of loops in IE11.
I also think it should be included in the es6 and maybe default set.
Most helpful comment
I am experiencing same issues. Running the code that is transpiled by the Babel and
Symbol.iteratoris missing from array objects. After explicitly requesting it withhttps://cdn.polyfill.io/v2/polyfill.js=features=Array.prototype.@@iteratorit works, but then I have to either do another request for remaining features or list them all there. Shouldn'tArray.prototype.@@iteratorbe part of default set sinceSymbol.iteratoris there?Similar issue goes with Set as well, no Symbol.iterator present, but in this case there isn't really a polyfill that would fix it. Although it strange. Now I see that Set polyfill already has iterator included, but after loading default polyfill for IE11 and running
Object.getOwnPropertySymbols(new Set())I am getting empty array.