From bfb9157186c237078cb1ac4998607d88242abe35 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 8 May 2023 08:34:16 +0200 Subject: [PATCH] Add value argument to URLSearchParams's has() and delete() Also add
wrappers. Tests: https://github.com/web-platform-tests/wpt/pull/39865. Fixes #335. --- url.bs | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/url.bs b/url.bs index 3442b610..3fb2a1f0 100644 --- a/url.bs +++ b/url.bs @@ -3700,10 +3700,10 @@ interface URLSearchParams { readonly attribute unsigned long size; undefined append(USVString name, USVString value); - undefined delete(USVString name); + undefined delete(USVString name, optional USVString value); USVString? get(USVString name); sequence<USVString> getAll(USVString name); - boolean has(USVString name); + boolean has(USVString name, optional USVString value); undefined set(USVString name, USVString value); undefined sort(); @@ -3761,8 +3761,9 @@ console.log(url.searchParams.get('b')); // "~" the potential to change that object's path in a manner equivalent to the {{URL}} object's {{URL/search}} and {{URL/hash}} setters. +

To initialize a -{{URLSearchParams}} object query with init, run these steps: +{{URLSearchParams}} object query with init:

  1. @@ -3791,9 +3792,11 @@ object's {{URL/search}} and {{URL/hash}} setters. parsing init.
+
+

To update a {{URLSearchParams}} -object query, run these steps: +object query:

  1. If query's URL object is null, then return. @@ -3811,7 +3814,9 @@ object query, run these steps: potentially strip trailing spaces from an opaque path with query's URL object.

+
+

The new URLSearchParams(init) constructor steps are:

@@ -3822,10 +3827,14 @@ constructor steps are:

  • Initialize this with init. +

  • +

    The size getter steps are to return this's list's size. +

    +

    The append(name, value) method steps are: @@ -3835,28 +3844,52 @@ method steps are:

  • Update this. +

  • -

    The delete(name) method steps are: +

    +

    The delete(name, value) +method steps are:

      -
    1. Remove all tuples whose name is name from +

    2. If value is given, then remove all tuples whose name + is name and value is value from this's + list. + +

    3. Otherwise, remove all tuples whose name is name from this's list.

    4. Update this.

    +
    +

    The get(name) method steps are to return the value of the first tuple whose name is name in this's list, if there is such a tuple; otherwise null. +

    +

    The getAll(name) method steps are to return the values of all tuples whose name is name in this's list, in list order; otherwise the empty sequence. +

    + +
    +

    The has(name, value) +method steps are: + +

      +
    1. If value is given and there is a tuple whose name is name + and value is value in this's list, then return true. -

      The has(name) method steps are to -return true if there is a tuple whose name is name in this's -list; otherwise false. +

    2. If value is not given and there is a tuple whose name is + name in this's list, then return true. +

    3. Return false. +

    +
    + +

    The set(name, value) method steps are: @@ -3870,6 +3903,7 @@ method steps are:

  • Update this. +


  • @@ -3891,6 +3925,7 @@ const sorted = new URLSearchParams(url.search) sorted.sort()
    +

    The sort() method steps are:

      @@ -3900,6 +3935,7 @@ sorted.sort()
    1. Update this.

    +

    @@ -3954,6 +3990,7 @@ Bobby Holley, Boris Zbarsky, Brad Hill, Brandon Ross, +Cailyn Hansen, Chris Dumez, Chris Rebert, Corey Farwell,