Skip to content

Commit bfb9157

Browse files
authored
Add value argument to URLSearchParams's has() and delete()
Also add <div algorithm> wrappers. Tests: web-platform-tests/wpt#39865. Fixes #335.
1 parent ae3c28b commit bfb9157

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

url.bs

+46-9
Original file line numberDiff line numberDiff line change
@@ -3700,10 +3700,10 @@ interface URLSearchParams {
37003700
readonly attribute unsigned long size;
37013701

37023702
undefined append(USVString name, USVString value);
3703-
undefined delete(USVString name);
3703+
undefined delete(USVString name, optional USVString value);
37043704
USVString? get(USVString name);
37053705
sequence&lt;USVString> getAll(USVString name);
3706-
boolean has(USVString name);
3706+
boolean has(USVString name, optional USVString value);
37073707
undefined set(USVString name, USVString value);
37083708

37093709
undefined sort();
@@ -3761,8 +3761,9 @@ console.log(url.searchParams.get('b')); // "~"</code></pre>
37613761
the potential to change that object's <a for=url>path</a> in a manner equivalent to the {{URL}}
37623762
object's {{URL/search}} and {{URL/hash}} setters.
37633763

3764+
<div algorithm>
37643765
<p>To <dfn for=URLSearchParams oldids=concept-urlsearchparams-new>initialize</dfn> a
3765-
{{URLSearchParams}} object <var>query</var> with <var>init</var>, run these steps:
3766+
{{URLSearchParams}} object <var>query</var> with <var>init</var>:
37663767

37673768
<ol>
37683769
<li>
@@ -3791,9 +3792,11 @@ object's {{URL/search}} and {{URL/hash}} setters.
37913792
<a lt="urlencoded string parser">parsing</a> <var>init</var>.
37923793
</ol>
37933794
</ol>
3795+
</div>
37943796

3797+
<div algorithm>
37953798
<p>To <dfn for=URLSearchParams id=concept-urlsearchparams-update>update</dfn> a {{URLSearchParams}}
3796-
object <var>query</var>, run these steps:
3799+
object <var>query</var>:
37973800

37983801
<ol>
37993802
<li><p>If <var>query</var>'s <a for=URLSearchParams>URL object</a> is null, then return.
@@ -3811,7 +3814,9 @@ object <var>query</var>, run these steps:
38113814
<a>potentially strip trailing spaces from an opaque path</a> with <var>query</var>'s
38123815
<a for=URLSearchParams>URL object</a>.
38133816
</ol>
3817+
</div>
38143818

3819+
<div algorithm>
38153820
<p>The
38163821
<dfn constructor for=URLSearchParams lt="URLSearchParams(init)"><code>new URLSearchParams(<var>init</var>)</code></dfn>
38173822
constructor steps are:</p>
@@ -3822,10 +3827,14 @@ constructor steps are:</p>
38223827

38233828
<li><p><a for=URLSearchParams>Initialize</a> <a>this</a> with <var>init</var>.
38243829
</ol>
3830+
</div>
38253831

3832+
<div algorithm>
38263833
<p>The <dfn attribute for=URLSearchParams><code>size</code></dfn> getter steps are to return
38273834
<a>this</a>'s <a for=URLSearchParams>list</a>'s <a for=list>size</a>.
3835+
</div>
38283836

3837+
<div algorithm>
38293838
<p>The <dfn method for=URLSearchParams><code>append(<var>name</var>, <var>value</var>)</code></dfn>
38303839
method steps are:
38313840

@@ -3835,28 +3844,52 @@ method steps are:
38353844

38363845
<li><p><a for=URLSearchParams>Update</a> <a>this</a>.
38373846
</ol>
3847+
</div>
38383848

3839-
<p>The <dfn method for=URLSearchParams><code>delete(<var>name</var>)</code></dfn> method steps are:
3849+
<div algorithm>
3850+
<p>The <dfn method for=URLSearchParams><code>delete(<var>name</var>, <var>value</var>)</code></dfn>
3851+
method steps are:
38403852

38413853
<ol>
3842-
<li><p><a for=list>Remove</a> all <a for=/>tuples</a> whose name is <var>name</var> from
3854+
<li><p>If <var>value</var> is given, then <a for=list>remove</a> all <a for=/>tuples</a> whose name
3855+
is <var>name</var> and value is <var>value</var> from <a>this</a>'s
3856+
<a for=URLSearchParams>list</a>.
3857+
3858+
<li><p>Otherwise, <a for=list>remove</a> all <a for=/>tuples</a> whose name is <var>name</var> from
38433859
<a>this</a>'s <a for=URLSearchParams>list</a>.
38443860

38453861
<li><p><a for=URLSearchParams>Update</a> <a>this</a>.
38463862
</ol>
3863+
</div>
38473864

3865+
<div algorithm>
38483866
<p>The <dfn method for=URLSearchParams><code>get(<var>name</var>)</code></dfn> method steps are to
38493867
return the value of the first <a for=/>tuple</a> whose name is <var>name</var> in <a>this</a>'s
38503868
<a for=URLSearchParams>list</a>, if there is such a <a for=/>tuple</a>; otherwise null.
3869+
</div>
38513870

3871+
<div algorithm>
38523872
<p>The <dfn method for=URLSearchParams><code>getAll(<var>name</var>)</code></dfn> method steps are
38533873
to return the values of all <a for=/>tuples</a> whose name is <var>name</var> in <a>this</a>'s
38543874
<a for=URLSearchParams>list</a>, in list order; otherwise the empty sequence.
3875+
</div>
3876+
3877+
<div algorithm>
3878+
<p>The <dfn method for=URLSearchParams><code>has(<var>name</var>, <var>value</var>)</code></dfn>
3879+
method steps are:
3880+
3881+
<ol>
3882+
<li><p>If <var>value</var> is given and there is a <a for=/>tuple</a> whose name is <var>name</var>
3883+
and value is <var>value</var> in <a>this</a>'s <a for=URLSearchParams>list</a>, then return true.
38553884

3856-
<p>The <dfn method for=URLSearchParams><code>has(<var>name</var>)</code></dfn> method steps are to
3857-
return true if there is a <a for=/>tuple</a> whose name is <var>name</var> in <a>this</a>'s
3858-
<a for=URLSearchParams>list</a>; otherwise false.
3885+
<li><p>If <var>value</var> is not given and there is a <a for=/>tuple</a> whose name is
3886+
<var>name</var> in <a>this</a>'s <a for=URLSearchParams>list</a>, then return true.
38593887

3888+
<li><p>Return false.
3889+
</ol>
3890+
</div>
3891+
3892+
<div algorithm>
38603893
<p>The <dfn method for=URLSearchParams><code>set(<var>name</var>, <var>value</var>)</code></dfn>
38613894
method steps are:
38623895

@@ -3870,6 +3903,7 @@ method steps are:
38703903

38713904
<li><p><a for=URLSearchParams>Update</a> <a>this</a>.
38723905
</ol>
3906+
</div>
38733907

38743908
<hr>
38753909

@@ -3891,6 +3925,7 @@ const sorted = new URLSearchParams(url.search)
38913925
sorted.sort()</code></pre>
38923926
</div>
38933927

3928+
<div algorithm>
38943929
<p>The <dfn method for=URLSearchParams><code>sort()</code></dfn> method steps are:
38953930

38963931
<ol>
@@ -3900,6 +3935,7 @@ sorted.sort()</code></pre>
39003935

39013936
<li><p><a for=URLSearchParams>Update</a> <a>this</a>.
39023937
</ol>
3938+
</div>
39033939

39043940
<hr>
39053941

@@ -3954,6 +3990,7 @@ Bobby Holley,
39543990
Boris Zbarsky,
39553991
Brad Hill,
39563992
Brandon Ross,
3993+
Cailyn Hansen,
39573994
Chris Dumez,
39583995
Chris Rebert,
39593996
Corey Farwell,

0 commit comments

Comments
 (0)