Skip to content

Incomplete Array.from polyfill in jsonata-es5 #432

@knolleary

Description

@knolleary

The es5 build includes the Array.from polyfill for IE11 (and earlier) compatibility. The polyfill has been taken from MDN - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Polyfill

Unfortunately this is an incomplete polyfill. In the spec it claims to be implementing, it is valid to pass an iterable (Set or Map) to the function. The polyfill fails to handle them - returning an empty array.

As you add the polyfill, I can't do a simple if (!Array.from) check. I need to test the behaviour of the function to see if I have to overwrite it with a more compliant version. The alternative is I load the polyfills before any vendor libraries are added. Either way, I have some changes to make.

I appreciate you don't need to use Array.from(<iterable>) in JSONata, however we do in Node-RED. I just spent ages tracking down which of our dependencies was adding the polyfill before we did... and here we are.

This issue is mostly FYI - I'll leave it to you to decide if you want to add a more complete polyfill.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions