Skip to content
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

URLSearchParams : [err] keys is not a function #1050

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions polyfills/URL/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ aliases = [
dependencies = [
"Object.defineProperties",
"Array.prototype.forEach",
"Array.isArray"
"Array.isArray",
"Array.from"
]
notes = [ "Polyfill requires Object getters so fails in IE < 8" ]
notes = [ "Polyfill requires Object getters so fails in IE <= 8" ]
license = "CC0-1.0"
repo = "https://github.com/inexorabletash/polyfill"
docs = "https://developer.mozilla.org/en-US/docs/Web/API/URL"
Expand Down
20 changes: 18 additions & 2 deletions polyfills/URL/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,27 @@
if (url.href === 'http://example.com/?a=1&b=2') {
url.search = '';
if (url.href === 'http://example.com/') {
if (!('sort' in global.URLSearchParams.prototype)) {
return false
}

var sp1 = new global.URLSearchParams('a=1');
var sp2 = new global.URLSearchParams(sp1);
if (String(sp2) === 'a=1') {
return true;
if (String(sp2) !== 'a=1') {
return false;
}

var sp3 = new global.URLSearchParams({a: '1'});
if (String(sp3) !== 'a=1') {
return false;
}

var sp4 = new global.URLSearchParams([['a', '1']]);
if (String(sp4) !== 'a=1') {
return false;
}

return true;
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions polyfills/URL/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
return false;
}

function toArray(iter) {
return ('from' in Array) ? Array.from(iter) : Array.prototype.slice.call(iter);
}

(function() {

// Browsers may have:
Expand Down Expand Up @@ -112,9 +108,9 @@
// In ES6 init would be a sequence, but special case for ES5.
this._list = urlencoded_parse(String(init));
} else if (typeof init === 'object' && isSequence(init)) {
toArray(init).forEach(function(e) {
Array.from(init).forEach(function(e) {
if (!isSequence(e)) throw TypeError();
var nv = toArray(e);
var nv = Array.from(e);
if (nv.length !== 2) throw TypeError();
$this._list.push({name: String(nv[0]), value: String(nv[1])});
});
Expand Down Expand Up @@ -505,9 +501,9 @@
global.URLSearchParams = function(init) {
if (init && typeof init === 'object' && isSequence(init)) {
var o = new orig();
toArray(init).forEach(function(e) {
Array.from(init).forEach(function (e) {
if (!isSequence(e)) throw TypeError();
var nv = toArray(e);
var nv = Array.from(e);
if (nv.length !== 2) throw TypeError();
o.append(nv[0], nv[1]);
});
Expand Down
Loading