polyfills icon indicating copy to clipboard operation
polyfills copied to clipboard

IE11 Symbol Issue

Open xjamundx opened this issue 5 years ago • 3 comments

In Internet Explorer 11 I get this error message when using the web components polyfill and lodash omitBy or pickBy.

Unable to get property '@@__symbol:iterator0.93819982581614551' of undefined or null reference

This is not a duplicate of #43, though there are some similarities.

This has occurred with other polyfills as well:

  • https://github.com/Financial-Times/polyfill-service/issues/1058
  • https://github.com/zloirock/core-js/commit/78770786a4e5f2f87ea32b4dada46b9ce0a92887

Lodash similarly has blocked the issue on their end, I believe thinking that polyfills need to resolve the issue: https://github.com/lodash/lodash/issues/2308

Some interesting things about reproduction:


This one will fail with the above error:

<script src="https://unpkg.com/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
<script>
var obj = {a: 1, b: 2}
var smaller = _.omitBy(obj, function (val) { return val > 1 })
console.log(smaller)
</script>

This one works fine:

<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/custom-elements-es5-adapter.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
<script>
var obj = {a: 1, b: 2}
var smaller = _.omitBy(obj, function (val) { return val > 1 })
console.log(smaller)
</script>

Does that just mean I'm using the wrong polyfill? My real use case is a complex webpack bundle thing with core-js and other, we first ran into #43 now this :)


Screen Shot 2020-05-05 at 11 13 05 AM


You can see it for yourself here: https://jsfiddle.net/s8yzcjne/3/embedded/result,css,html,js

xjamundx avatar May 05 '20 18:05 xjamundx

A workaround that works if you have webpack is to alias lodash.pickBy to a local module that exports its own pickBy method.

function pickBy(obj, pickFn) {
    return Object.fromEntries(
        Object.entries(obj).filter(([, value]) => {
            return pickFn(value);
        })
    );
}

export default pickBy;
export { pickBy };

xjamundx avatar May 05 '20 18:05 xjamundx

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 22 '21 09:05 stale[bot]

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!

stale[bot] avatar Sep 17 '23 16:09 stale[bot]