mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 12:07:14 +02:00
LibWeb/HTML: Properly get the attr-associated element
This replaces ad-hoc implementations of the get the attr-associated element steps with a call to the proper implementation. This fixes issue #8585.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
4110a05684
commit
88167149f6
Notes:
github-actions[bot]
2026-03-25 22:15:22 +00:00
Author: https://github.com/skyz1 Commit: https://github.com/LadybirdBrowser/ladybird/commit/88167149f6e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8602 Reviewed-by: https://github.com/gmta ✅
@@ -183,20 +183,7 @@ void HTMLButtonElement::activation_behavior(DOM::Event const& event)
|
||||
}
|
||||
|
||||
// 4. Let target be the result of running element's get the commandfor-associated element.
|
||||
// AD-HOC: Target needs to be an HTML Element in the following steps.
|
||||
GC::Ptr<HTMLElement> target = as_if<HTMLElement>(m_command_for_element.ptr());
|
||||
if (!target) {
|
||||
auto target_id = attribute(AttributeNames::commandfor);
|
||||
if (target_id.has_value()) {
|
||||
root().for_each_in_inclusive_subtree_of_type<HTMLElement>([&](auto& candidate) {
|
||||
if (candidate.attribute(HTML::AttributeNames::id) == target_id.value()) {
|
||||
target = &candidate;
|
||||
return TraversalDecision::Break;
|
||||
}
|
||||
return TraversalDecision::Continue;
|
||||
});
|
||||
}
|
||||
}
|
||||
auto target = get_the_attribute_associated_element(AttributeNames::commandfor, m_command_for_element);
|
||||
|
||||
// 5. If target is not null:
|
||||
if (target) {
|
||||
|
||||
Reference in New Issue
Block a user