mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 02:09:24 +00:00
LibWeb: Make URLSearchParams iterable
This uses the new support for the iterable IDL property.
This commit is contained in:
parent
14e99b9b68
commit
01417c82c5
Notes:
sideshowbarker
2024-07-18 03:22:44 +09:00
Author: https://github.com/IdanHo
Commit: 01417c82c5
Pull-request: https://github.com/SerenityOS/serenity/pull/10236
7 changed files with 101 additions and 2 deletions
|
@ -195,4 +195,13 @@ String URLSearchParams::to_string()
|
|||
return url_encode(m_list, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded);
|
||||
}
|
||||
|
||||
void URLSearchParams::for_each(Function<IterationDecision(String const&, String const&)> callback)
|
||||
{
|
||||
for (auto i = 0u; i < m_list.size(); ++i) {
|
||||
auto& query_param = m_list[i]; // We are explicitly iterating over the indices here as the callback might delete items from the list
|
||||
if (callback(query_param.name, query_param.value) == IterationDecision::Break)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue