mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #22638 - CYBAI:urlsearchparams-sort, r=nox
Implement URLSearchParams.prototype.sort() --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #22545 - [x] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22638) <!-- Reviewable:end -->
This commit is contained in:
commit
2e15cf0f81
4 changed files with 14 additions and 113 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())
|
||||
|
@ -182,9 +193,7 @@ impl URLSearchParams {
|
|||
.extend_pairs(&*list)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl URLSearchParams {
|
||||
// https://url.spec.whatwg.org/#concept-urlsearchparams-update
|
||||
fn update_steps(&self) {
|
||||
if let Some(url) = self.url.root() {
|
||||
|
|
|
@ -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