mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 00:54:57 +00:00
LibHTML: Add TreeNode::for_each_in_subtree_of_type<T>()
This allows you to iterate a subtree and get a callback for every node where is<T>(node) == true. This makes for quite pleasant DOM traversal.
This commit is contained in:
parent
54bd322881
commit
1aea8f116b
5 changed files with 56 additions and 25 deletions
|
@ -34,12 +34,10 @@ void HTMLFormElement::submit()
|
|||
|
||||
Vector<NameAndValue> parameters;
|
||||
|
||||
for_each_in_subtree([&](auto& node) {
|
||||
if (is<HTMLInputElement>(node)) {
|
||||
auto& input = to<HTMLInputElement>(node);
|
||||
if (!input.name().is_null())
|
||||
parameters.append({ input.name(), input.value() });
|
||||
}
|
||||
for_each_in_subtree_of_type<HTMLInputElement>([&](auto& node) {
|
||||
auto& input = to<HTMLInputElement>(node);
|
||||
if (!input.name().is_null())
|
||||
parameters.append({ input.name(), input.value() });
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue