mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add value argument to URLSearchParams's has() and delete()
This commit should fix #29725. Signed-off-by: Veronika Bušů <paricbat@email.cz>
This commit is contained in:
parent
419c03182f
commit
e40ec79f65
4 changed files with 14 additions and 20 deletions
|
@ -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
|
||||
|
|
|
@ -11,10 +11,10 @@ interface URLSearchParams {
|
|||
[Throws] constructor(optional (sequence<sequence<USVString>> or record<USVString, USVString> or USVString) init = "");
|
||||
readonly attribute unsigned long size;
|
||||
undefined append(USVString name, USVString value);
|
||||
undefined delete(USVString name);
|
||||
undefined delete(USVString name, optional USVString value);
|
||||
USVString? get(USVString name);
|
||||
sequence<USVString> getAll(USVString name);
|
||||
boolean has(USVString name);
|
||||
boolean has(USVString name, optional USVString value);
|
||||
undefined set(USVString name, USVString value);
|
||||
|
||||
undefined sort();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue