Skip to content

Commit

Permalink
Add URLSearchParams.prototype.sort()
Browse files Browse the repository at this point in the history
This method is added to increase cache hits when making requests. It’s
opt-in as the order of code points in a URL’s query is significant by
default. It’s up to applications to decide if name order is not
significant for them.

Tests: web-platform-tests/wpt#4531.

Fixes #26.
  • Loading branch information
annevk committed Jan 12, 2017
1 parent a7ae1b8 commit 98d6bbf
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2765,6 +2765,9 @@ interface URLSearchParams {
sequence<USVString> getAll(USVString name);
boolean has(USVString name);
void set(USVString name, USVString value);

void sort();

iterable<USVString, USVString>;
stringifier;
};
Expand Down Expand Up @@ -2843,6 +2846,11 @@ method, when invoked, must return the value of the first name-value pair whose n
method, when invoked, must return the values of all name-value pairs whose name is <var>name</var>,
in <a for=URLSearchParams>list</a>, in list order, and the empty sequence otherwise.

<p>The
<dfn method for=URLSearchParams><code>has(<var>name</var>)</code></dfn>
method, when invoked, must return true if there is a name-value pair whose name is <var>name</var>
in <a for=URLSearchParams>list</a>, and false otherwise.

<p>The
<dfn method for=URLSearchParams><code>set(<var>name</var>, <var>value</var>)</code></dfn>
method, when invoked, must run these steps:
Expand All @@ -2858,10 +2866,19 @@ method, when invoked, must run these steps:
<li><p>Run the <a for=URLSearchParams>update steps</a>.
</ol>

<p>The
<dfn method for=URLSearchParams><code>has(<var>name</var>)</code></dfn>
method, when invoked, must return true if there is a name-value pair whose name is <var>name</var>
in <a for=URLSearchParams>list</a>, and false otherwise.
<hr>

<p>The <dfn method for=URLSearchParams><code>sort()</code></df> method, when invoked, must run these
steps:
<ol>
<li><p>Lexicographically sort all name-value pairs, if any, by name, while preserving the relative
order between duplicate names, if any.
<li><p>Run the <a for=URLSearchParams>update steps</a>.
</ol>
<hr>
<p>The <a>value pairs to iterate over</a> are the
<a for=URLSearchParams>list</a> name-value pairs with the key being
Expand Down

0 comments on commit 98d6bbf

Please sign in to comment.