url: simplify constructor URLSearchParams. Remove needless check null

PR-URL: https://github.com/nodejs/node/pull/18700
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Mihail Bodrov 2018-02-10 19:38:45 +03:00 committed by Gus Caplan
parent a1bab826c4
commit 316846b8de

View File

@ -98,8 +98,7 @@ class URLSearchParams {
constructor(init = undefined) { constructor(init = undefined) {
if (init === null || init === undefined) { if (init === null || init === undefined) {
this[searchParams] = []; this[searchParams] = [];
} else if ((typeof init === 'object' && init !== null) || } else if (typeof init === 'object' || typeof init === 'function') {
typeof init === 'function') {
const method = init[Symbol.iterator]; const method = init[Symbol.iterator];
if (method === this[Symbol.iterator]) { if (method === this[Symbol.iterator]) {
// While the spec does not have this branch, we can use it as a // While the spec does not have this branch, we can use it as a