-
Notifications
You must be signed in to change notification settings - Fork 89
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
Polyfill for URL.prototype.searchParams #12
Comments
Maybe you can do like this: if (window.URL) {
Object.defineProperty(URL.prototype, 'searchParams', {
get: function () {
return new URLSearchParams(this.search)
}
})
} |
@jerrybendy but I can't do something like |
@xekri You are right. If you do that, every time you get the So, var u = new URL('http://github.com')
u.searchParams === u.searchParams // should be `true`, but `false` returned It causes a bug. To fix this bug, we should add a private variable to It is not necessary for most of users, so I didn't put it in the |
Thanks for this amazing tool. Was this feature added? |
@jhenry9636 Not yet. But you can use a workaround like above. I didn't write this solution into this library, because I don't want to make it fatter. |
It is my solution. This can still be improved.
|
@xyy94813 Your solution is better. Based on your code, We'd better rewrite all methods which can modify the URLSearchParams object, like Although 👍 |
I found that see: We can use it in the browser. And learn from its implementation |
URL instance supports
searchParams
member which isURLSearchParams
. It will be great to support this here.The text was updated successfully, but these errors were encountered: