I've been trying to track this one down for a while now, and though I know where the failure is, it isn't clear as to the best resolution.
Here is an isolated codepen that demonstrates that when poly+lodash+IE11 is combined, will blow up with:
"TypeError: Unable to get property '@@__symbol:iterator0.0365778717409362961' of undefined or null reference
at propertyIsEnumerable (https://cdn.polyfill.io/v2/polyfill.js?features=default,Array.prototype.@@iterator:244:3)
at Anonymous function (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:6056:9)
at arrayFilter (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:603:7)
at Anonymous function (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:6055:7)
at Anonymous function (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:6070:9)
at baseGetAllKeys (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:3064:7)
at getAllKeysIn (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:5903:7)
at Anonymous function (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:13485:7)
at apply (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:496:15)
at Anonymous function (https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js:6600:9)"
http://codepen.io/asilvas/pen/VPaOjz
Deps:
This is the line of the failure: https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/Symbol/polyfill.js#L84
Where this[internalSymbol]['@@' + uid] assumes that this[internalSymbol] is always defined, but is not the case. Of course, might just be able to add a conditional and be done with it, but appears this code behaves this way for a reason. So I'm guessing a resolution is needed elsewhere.
I've also been able to force this error (by overriding native polyfills) in other browsers like Chrome, but the codepen won't do that in its current form.
What appears to be a near identical issue was found before with core-js in reference to lodash: https://github.com/lodash/lodash/issues/2308
Which was supposedly fixed. It's not clear if that fix could somehow help in addressing this.
We aren't using Lodash but we are getting the same error with IE11:
SCRIPT5007: Unable to get property '@@__symbol:iterator0.6412312131232' of undefined or null reference'
File: polyfill.js, Line: 780, Column: 3
@xer0x do you have simple example code for repro?
Sorry @asilvas we only just started hitting this. We've been using polyfill with no problems for awhile. We haven't found what changes yet
UPDATE: it looks like our issue is with https://github.com/zenorocha/clipboard.js & polyfill on ie11
UPDATE 2: it looks like lodash and polyfill.
I have run into this issue as well. What seems to be happening is that lodash calls Object.prototype.propertyIsEnumerable. However, polyfill-service's implementation of propertyIsEnumerable seems to be incorrect for polyfilled Symbols. The polyfill-service implementation returns true for symbol properties, even if they were defined with {enumerable: false}, which seems to be a bug.
Note that this bug affects any code that uses Object.prototype.propertyIsEnumerable when in combination with the Array.prototype.@@iterator polyfill-service. I am still not sure exactly how propertyIsEnumerable is returning true for the iterator symbol on the Array prototype, but that's what I think is happening.
There was an issue created in lodash that's exactly the same bug: https://github.com/lodash/lodash/issues/2308
Apparently the bug on core-js was fixed in https://github.com/zloirock/core-js/commit/78770786a4e5f2f87ea32b4dada46b9ce0a92887. Perhaps we can port the fix somehow?
@satazor Nice find! I'm happy to accept a PR which fixes the issue in the same manner as core-js' solution :-)
I've spent some time trying to resolve, but appears to be over my head. I suspect it might be simple for someone more familiar with these polyfills. Anyone with more experience with these polyfills have time to take a look? Would be much appreciated... @triblondon @jonathantneal @JakeChampion ?
@asilvas I could take a look on this, as this affects us also.
Sorry @asilvas, I've been working on our selenium testing suite as their are two bugs in it which are stopping me from making a new release of the service. Once I've finished this work I will be taking a look through the issues on the project.
@hannesj Thanks for offering to help out on this issue :-D If you need any help, feel free to message on this issue and tag me.
Checking in, any luck? @hannesj @JakeChampion
It seems this bug also effects Safari versions < 9.
I also want to give it a try. This is hitting us pretty badly.
Thanks @asilvas, very generous of you. I don't know enough about symbols to take this on but hopefully someone else can help. It looks like we are using a modified version of https://github.com/WebReflection/get-own-property-symbols, so testing with that source might be a good place to start.
@rhalukongor thanks very much for the fix!
@JakeChampion was the fix already deployed?
@satazor It will be out in v3.17 :-)
@rhalukongor don't forget to claim the bounty, thanks!
Most helpful comment
It seems this bug also effects Safari versions < 9.
I also want to give it a try. This is hitting us pretty badly.