mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Implement URLSearchParams.prototype.sort()
This commit is contained in:
parent
b5276194f4
commit
f43c604bf3
4 changed files with 14 additions and 111 deletions
|
@ -168,6 +168,17 @@ impl URLSearchParamsMethods for URLSearchParams {
|
|||
self.update_steps();
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-sort
|
||||
fn Sort(&self) {
|
||||
// Step 1.
|
||||
self.list
|
||||
.borrow_mut()
|
||||
.sort_by(|(a, _), (b, _)| a.encode_utf16().cmp(b.encode_utf16()));
|
||||
|
||||
// Step 2.
|
||||
self.update_steps();
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#stringification-behavior
|
||||
fn Stringifier(&self) -> DOMString {
|
||||
DOMString::from(self.serialize_utf8())
|
||||
|
|
|
@ -16,6 +16,9 @@ interface URLSearchParams {
|
|||
sequence<USVString> getAll(USVString name);
|
||||
boolean has(USVString name);
|
||||
void set(USVString name, USVString value);
|
||||
|
||||
void sort();
|
||||
|
||||
// Be careful with implementing iterable interface.
|
||||
// Search params might be mutated by URL::SetSearch while iterating (discussed in PR #10351).
|
||||
iterable<USVString, USVString>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue