diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/url/00_url.js | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/ext/url/00_url.js b/ext/url/00_url.js index 2a238eae1..65cde2ce2 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -169,19 +169,31 @@ class URLSearchParams { /** * @param {string} name + * @param {string} [value] */ - delete(name) { + delete(name, value = undefined) { webidl.assertBranded(this, URLSearchParamsPrototype); const prefix = "Failed to execute 'append' on 'URLSearchParams'"; webidl.requiredArguments(arguments.length, 1, prefix); name = webidl.converters.USVString(name, prefix, "Argument 1"); const list = this[_list]; let i = 0; - while (i < list.length) { - if (list[i][0] === name) { - ArrayPrototypeSplice(list, i, 1); - } else { - i++; + if (value === undefined) { + while (i < list.length) { + if (list[i][0] === name) { + ArrayPrototypeSplice(list, i, 1); + } else { + i++; + } + } + } else { + value = webidl.converters.USVString(value, prefix, "Argument 2"); + while (i < list.length) { + if (list[i][0] === name && list[i][1] === value) { + ArrayPrototypeSplice(list, i, 1); + } else { + i++; + } } } this.#updateUrlSearch(); @@ -228,13 +240,21 @@ class URLSearchParams { /** * @param {string} name + * @param {string} [value] * @return {boolean} */ - has(name) { + has(name, value = undefined) { webidl.assertBranded(this, URLSearchParamsPrototype); const prefix = "Failed to execute 'has' on 'URLSearchParams'"; webidl.requiredArguments(arguments.length, 1, prefix); name = webidl.converters.USVString(name, prefix, "Argument 1"); + if (value !== undefined) { + value = webidl.converters.USVString(value, prefix, "Argument 2"); + return ArrayPrototypeSome( + this[_list], + (entry) => entry[0] === name && entry[1] === value, + ); + } return ArrayPrototypeSome(this[_list], (entry) => entry[0] === name); } |