1 | url-search-params
|
2 | =================
|
3 |
|
4 | [![build status](https://secure.travis-ci.org/WebReflection/url-search-params.svg)](http://travis-ci.org/WebReflection/url-search-params)
|
5 |
|
6 | This is a polyfill for the [URLSearchParams API](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).
|
7 |
|
8 | It is possible to simply include [build/url-search-params.js](build/url-search-params.js) or grab it via npm.
|
9 |
|
10 | ```
|
11 | npm install url-search-params
|
12 | ```
|
13 |
|
14 | The function is exported directly.
|
15 | ```js
|
16 | var URLSearchParams = require('url-search-params');
|
17 | ```
|
18 |
|
19 | MIT Style License
|
20 |
|
21 | #### About HTMLAnchorElement.prototype.searchParams
|
22 | This property is already implemented in Firefox and polyfilled here only for browsers that exposes getters and setters
|
23 | through the `HTMLAnchorElement.prototype`.
|
24 |
|
25 | In order to know if such property is supported, you **must** do the check as such:
|
26 | ```
|
27 | if ('searchParams' in HTMLAnchorElement.prototype) {
|
28 | // polyfill for <a> links supported
|
29 | }
|
30 | ```
|
31 | If you do this check instead:
|
32 | ```js
|
33 | if (HTMLAnchorElement.prototype.searchParams) {
|
34 | // throws a TypeError
|
35 | }
|
36 | ```
|
37 | this polyfill will reflect native behavior, throwing a type error due access to a property in a non instance of `HTMLAnchorElement`.
|
38 |
|
39 | Nothing new to learn here, [just a reminder](http://webreflection.blogspot.co.uk/2011/08/please-stop-reassigning-for-no-reason.html).
|