Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete Array.from polyfill in jsonata-es5 #432

Closed
knolleary opened this issue Apr 3, 2020 · 1 comment · Fixed by #436
Closed

Incomplete Array.from polyfill in jsonata-es5 #432

knolleary opened this issue Apr 3, 2020 · 1 comment · Fixed by #436
Labels

Comments

@knolleary
Copy link
Contributor

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.

@andrew-coleman
Copy link
Member

Probably I should remove the polyfill entirely and rewrite the code that uses it, since I only need a small fraction of its capability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants