Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

URLSearchParams: keys is not a function #1048

Closed
DomenicoCasillo opened this issue May 7, 2021 · 4 comments · Fixed by #1050
Closed

URLSearchParams: keys is not a function #1048

DomenicoCasillo opened this issue May 7, 2021 · 4 comments · Fixed by #1050
Labels
library Relates to an Origami library

Comments

@DomenicoCasillo
Copy link

DomenicoCasillo commented May 7, 2021

Bug Report

What

URLSearchParams polyfill (v3) seems to be incomplete in Firefox 37 Desktop.

Details

const urlParams = new URLSearchParams(location.search);
console.log(urlParams.keys());

The urlParams object is correctly created but on the second line, an error is triggered with
TypeError: urlParams.keys is not a function

Browser: Firefox 37 Desktop (Mozilla/5.0 (Windows NT 6.1; rv:37.0) Gecko/20100101 Firefox/37.0)
Device: Desktop
Polyfill URL: https://polyfill.io/v3/polyfill.min.js?features=Promise.prototype.finally%2CPromise%2CURLSearchParams%2CArray.prototype.flatMap

@JakeChampion JakeChampion transferred this issue from polyfillpolyfill/polyfill-service May 7, 2021
@github-actions github-actions bot added the library Relates to an Origami library label May 7, 2021
@JakeChampion
Copy link
Owner

@DomenicoCasillo, thanks for the issue, could you please post the full polyfill.io url you are using and the full user-agent of the browser which is seeing the issue please? With that information we should hopefully be able to find the cause of the problem

@DomenicoCasillo
Copy link
Author

@DomenicoCasillo, thanks for the issue, could you please post the full polyfill.io url you are using and the full user-agent of the browser which is seeing the issue please? With that information we should hopefully be able to find the cause of the problem

I've updated the initial post with additional details. I can add that even entries and values are not available.

image

@JakeChampion
Copy link
Owner

Thanks @DomenicoCasillo - I have confirmed the issue now 👍

This is happening because the polyfill has not been applied, you can see that if you run URLSearchParams.toString(), it will return this:

"function URLSearchParams() {
    [native code]
}"

That is happening because Firefox 37 passes all the checks in this section of code:
https://github.com/Financial-Times/polyfill-library/blob/2cfa74e454bf6736234bad9bdeca5d96d451ebc2/polyfills/URL/polyfill.js#L36-L45

We need to update that section of code to check for the methods you've mentioned: keys, values, entries.

If you submit a pull-request which does that, I'm happy to review it 👍

@romainmenke
Copy link
Collaborator

romainmenke commented May 7, 2021

Bit of a rabbit hole :)

One of the reasons it is not working as expected is because there are a few missing dependencies and Array.from also seems to be needed in more browser versions than currently stated.

I'll take a look and patch the needed pieces.
Also adding tests from WPT to have extra coverage.


Update : Array.from itself seems fine.

romainmenke added a commit to romainmenke/polyfill-library that referenced this issue May 7, 2021
romainmenke added a commit to romainmenke/polyfill-library that referenced this issue May 7, 2021
romainmenke added a commit to romainmenke/polyfill-library that referenced this issue May 7, 2021
romainmenke added a commit to romainmenke/polyfill-library that referenced this issue May 7, 2021
Origami ✨ automation moved this from incoming to complete May 7, 2021
JakeChampion pushed a commit that referenced this issue May 7, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2021
@robertboulton robertboulton removed this from Done in Origami ✨ Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
library Relates to an Origami library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants