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

"Invalid Argument" on "new URLSearchParams(formData.entries())" in Edge 44.18362.449.0 #56

Open
FagnerMartinsBrack opened this issue Apr 15, 2020 · 3 comments

Comments

@FagnerMartinsBrack
Copy link

FagnerMartinsBrack commented Apr 15, 2020

It seems url-polyfill is not detecting an incorrect behaviour from edge and therefore not polyfilling the whole URLSearchParams with standard behaviour. Even if I add the polyfill before the code, it falls back to edge behaviour which breaks the code, requiring custom browser workaround.

Failing code:

const formData = new FormData(event.target);
alert(new URLSearchParams([...formData.entries()]).toString());

SSCCE that fails on Edge and includes the polyfill in "resources": https://jsfiddle.net/v138s4x2/

If you use spread, it works. Here's my workaround at the moment:

const formData = new FormData(event.target);
alert(new URLSearchParams([...formData.entries()]).toString());

The reason is outlined here:

The problem in Edge is that they do not support destructuring of FormData object. (for ... of in linked table).

Expected behavior:

The polyfill detects and intercepts the faulty behavior from Edge and overrides URLSearchParams with standard behavior

@lifaon74
Copy link
Owner

Yes, this is a legit behavior: the introduction of Symbol.iterable is pretty recent, just like classes/functions accepting them as input. This polyfill currently doesn't support iterables as input to support IE. But this could be easily solved by using iteratorSupported in the constructor.

I see 2 solutions for you:

  1. new URLSearchParams(Array.from(formData.entries()))
  2. Do a pull request which solves this problem

@FagnerMartinsBrack
Copy link
Author

@lifaon74 Thanks for the response :)

I'm trying to run the tests locally to create a failing test and eventually a PR. However, there are a lot of moving parts. Do you know a step by step on how to run the tests for EDGE on Mac? If not that's fine I'll spend some time to try to figure this out.

@lifaon74
Copy link
Owner

The test are currently running on my own selenium test server. You may change the url here: https://github.com/lifaon74/url-polyfill/blob/master/tests/config.json

You may try to update the code, verify if everything works on your side, then do a pull request. I'll run the tests myself for your PR.

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

No branches or pull requests

2 participants