mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-20 16:28:54 +00:00
LibWeb: Implement value argument of URLSearchParams.delete
This commit is contained in:
parent
e2fb24c9b8
commit
5637dc43b2
Notes:
github-actions[bot]
2024-08-12 22:02:50 +00:00
Author: https://github.com/shannonbooth
Commit: 5637dc43b2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1033
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 37 additions and 7 deletions
|
@ -231,12 +231,22 @@ WebIDL::ExceptionOr<void> URLSearchParams::update()
|
|||
return {};
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> URLSearchParams::delete_(String const& name)
|
||||
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
|
||||
WebIDL::ExceptionOr<void> URLSearchParams::delete_(String const& name, Optional<String> const& value)
|
||||
{
|
||||
// 1. Remove all name-value pairs whose name is name from list.
|
||||
m_list.remove_all_matching([&name](auto& entry) {
|
||||
return entry.name == name;
|
||||
});
|
||||
// 1. If value is given, then remove all tuples whose name is name and value is value from this’s list.
|
||||
if (value.has_value()) {
|
||||
m_list.remove_all_matching([&name, &value](auto& entry) {
|
||||
return entry.name == name && entry.value == value.value();
|
||||
});
|
||||
}
|
||||
// 2. Otherwise, remove all tuples whose name is name from this’s list.
|
||||
else {
|
||||
m_list.remove_all_matching([&name](auto& entry) {
|
||||
return entry.name == name;
|
||||
});
|
||||
}
|
||||
|
||||
// 2. Update this.
|
||||
TRY(update());
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
size_t size() const;
|
||||
WebIDL::ExceptionOr<void> append(String const& name, String const& value);
|
||||
WebIDL::ExceptionOr<void> delete_(String const& name);
|
||||
WebIDL::ExceptionOr<void> delete_(String const& name, Optional<String> const& value = {});
|
||||
Optional<String> get(String const& name);
|
||||
WebIDL::ExceptionOr<Vector<String>> get_all(String const& name);
|
||||
bool has(String const& name);
|
||||
|
|
|
@ -7,7 +7,7 @@ interface URLSearchParams {
|
|||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue