url-search-params-polyfill
Advanced tools
Comparing version 8.1.1 to 8.2.0
23
index.js
@@ -1,9 +0,7 @@ | ||
/** | ||
/**! | ||
* url-search-params-polyfill | ||
* | ||
* | ||
* @author Jerry Bendy <jerry@icewingcc.com> | ||
* @author Jerry Bendy (https://github.com/jerrybendy) | ||
* @licence MIT | ||
* | ||
*/ | ||
(function(self) { | ||
@@ -24,2 +22,3 @@ 'use strict'; | ||
decodesPlusesCorrectly = nativeURLSearchParams && (new nativeURLSearchParams('s=%2B').get('s') === '+'), | ||
isSupportSize = !!nativeURLSearchParams.prototype.size, | ||
__URLSearchParams__ = "__URLSearchParams__", | ||
@@ -35,3 +34,3 @@ // Fix bug in Edge which cannot encode ' &' correctly | ||
if (nativeURLSearchParams && isSupportObjectConstructor && decodesPlusesCorrectly && encodesAmpersandsCorrectly) { | ||
if (nativeURLSearchParams && isSupportObjectConstructor && decodesPlusesCorrectly && encodesAmpersandsCorrectly && isSupportSize) { | ||
return; | ||
@@ -155,3 +154,3 @@ } | ||
/* | ||
* Apply polifill to global object and append other prototype into it | ||
* Apply polyfill to global object and append other prototype into it | ||
*/ | ||
@@ -248,2 +247,12 @@ Object.defineProperty(self, 'URLSearchParams', { | ||
if (!USPProto.size) { | ||
Object.defineProperty(USPProto, 'size', { | ||
get: function () { | ||
var that = this | ||
return Object.keys(this[__URLSearchParams__]).reduce(function (prev, cur) { | ||
return prev + that[__URLSearchParams__][cur].length; | ||
}, 0); | ||
} | ||
}); | ||
} | ||
@@ -250,0 +259,0 @@ function encode(str) { |
{ | ||
"name": "url-search-params-polyfill", | ||
"version": "8.1.1", | ||
"version": "8.2.0", | ||
"description": "a simple polyfill for javascript URLSearchParams", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/jerrybendy/url-search-params-polyfill", |
@@ -148,2 +148,7 @@ # URLSearchParams Polyfill [![](https://img.shields.io/npm/v/url-search-params-polyfill.svg)](https://www.npmjs.com/package/url-search-params-polyfill) | ||
### size | ||
```javascript | ||
console.log(search.size) | ||
``` | ||
## Known Issues | ||
@@ -150,0 +155,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16705
321
186