IE11 bug with Symbols and Enumerables exposed by lodash.omit
See original GitHub issueI’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:
- https://cdn.polyfill.io/v2/polyfill.js?features=default,Array.prototype.@@iterator
- https://cdn.jsdelivr.net/lodash/4.17.4/lodash.js
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.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:16 (8 by maintainers)
It seems this bug also effects Safari versions < 9. I also want to give it a try. This is hitting us pretty badly.
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 ofpropertyIsEnumerable
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 howpropertyIsEnumerable
is returning true for the iterator symbol on the Array prototype, but that’s what I think is happening.