mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +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:
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user