diff options
author | Veronika Bušů <paricbat@email.cz> | 2023-05-08 19:47:29 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-05-11 08:34:17 +0200 |
commit | e40ec79f6531cf57e57173861610b2e2a9fdd46b (patch) | |
tree | 8940de31aa4868b3d92d849c61e3c63979ebef6e /components/script/dom/urlsearchparams.rs | |
parent | 419c03182f93542424c21f50da8d14358e46a6bd (diff) | |
download | servo-e40ec79f6531cf57e57173861610b2e2a9fdd46b.tar.gz servo-e40ec79f6531cf57e57173861610b2e2a9fdd46b.zip |
Add value argument to URLSearchParams's has() and delete()
This commit should fix #29725.
Signed-off-by: Veronika Bušů <paricbat@email.cz>
Diffstat (limited to 'components/script/dom/urlsearchparams.rs')
-rw-r--r-- | components/script/dom/urlsearchparams.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs index 923d8f9e6ad..4b7e2880ef1 100644 --- a/components/script/dom/urlsearchparams.rs +++ b/components/script/dom/urlsearchparams.rs @@ -105,9 +105,14 @@ impl URLSearchParamsMethods for URLSearchParams { } // https://url.spec.whatwg.org/#dom-urlsearchparams-delete - fn Delete(&self, name: USVString) { + fn Delete(&self, name: USVString, value: Option<USVString>) { // Step 1. - self.list.borrow_mut().retain(|&(ref k, _)| k != &name.0); + self.list + .borrow_mut() + .retain(|&(ref k, ref v)| match &value { + Some(value) => !(k == &name.0 && v == &value.0), + None => k != &name.0, + }); // Step 2. self.update_steps(); } @@ -135,9 +140,12 @@ impl URLSearchParamsMethods for URLSearchParams { } // https://url.spec.whatwg.org/#dom-urlsearchparams-has - fn Has(&self, name: USVString) -> bool { + fn Has(&self, name: USVString, value: Option<USVString>) -> bool { let list = self.list.borrow(); - list.iter().any(|&(ref k, _)| k == &name.0) + list.iter().any(|&(ref k, ref v)| match &value { + Some(value) => k == &name.0 && v == &value.0, + None => k == &name.0, + }) } // https://url.spec.whatwg.org/#dom-urlsearchparams-set |