LibWeb: Implement the :default pseudo-class

This commit is contained in:
Gingeh 2025-05-24 15:24:38 +10:00 committed by Sam Atkins
parent 7acc0f4a42
commit 3fe148f2d4
Notes: github-actions[bot] 2025-05-24 09:32:32 +00:00
9 changed files with 115 additions and 3 deletions

View file

@ -1176,13 +1176,13 @@ JS::Value HTMLFormElement::named_item_value(FlyString const& name) const
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#default-button
FormAssociatedElement* HTMLFormElement::default_button()
FormAssociatedElement* HTMLFormElement::default_button() const
{
// A form element's default button is the first submit button in tree order whose form owner is that form element.
FormAssociatedElement* default_button = nullptr;
root().for_each_in_subtree([&](auto& node) {
auto* form_associated_element = dynamic_cast<FormAssociatedElement*>(&node);
auto* form_associated_element = const_cast<FormAssociatedElement*>(dynamic_cast<FormAssociatedElement const*>(&node));
if (!form_associated_element)
return TraversalDecision::Continue;