question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Polyfill for URL.prototype.searchParams

See original GitHub issue

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
xyy94813commented, Nov 27, 2019

@jerrybendy

I found that core-js already supports URL and URLSearchParmas compatibility.

see: https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/web.url.js https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/web.url-search-params.js

We can use it in the browser. And learn from its implementation

1reaction
xyy94813commented, May 16, 2019

It is my solution. This can still be improved.

if (URL) {
  Object.defineProperty(URL.prototype, 'searchParams', {
    get (context) {
      const searchParams = new URLSearchParams(this.search)
      searchParams.set = (key, value) => {
        URLSearchParams.prototype.set.call(searchParams, key, value)
        this.search = `?${searchParams.toString()}`
      }
      searchParams.delete = (key, value) => {
        URLSearchParams.prototype.delete.call(searchParams, key, value)
        this.search = `?${searchParams.toString()}`
      }
      return searchParams
    }
  })
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

url-search-params-polyfill - npm
a simple polyfill for javascript URLSearchParams. Latest version: 8.1.1, last published: 2 years ago. Start using url-search-params-polyfill ...
Read more >
URL - The Vanilla JS Toolkit
URL Polyfill * Draft specification: https://url.spec.whatwg.org ... may have a dummy constructor // * URL with members except searchParams // * Full URL...
Read more >
url-search-params - npm.io
Check Url-search-params 1.1.0 package - Last release 1.1.0 with MIT ... if ('searchParams' in HTMLAnchorElement.prototype) { // polyfill for <a> links ...
Read more >
URL builder - Polyfill.io
Polyfill.io. ... Callback Name of the function to call after the polyfills are loaded. Minify bundle Have the polyfill bundle be ... URL.prototype.toJSON...
Read more >
url-search-params - UNPKG
The CDN for url-search-params. ... 6, This is a polyfill for the [URLSearchParams ... 27, if ('searchParams' in HTMLAnchorElement.prototype) {.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found