LibWeb: Allow focusable for the first summary child of a detail element

This commit is contained in:
Lorenz A 2025-11-11 14:07:52 +01:00 committed by Jelle Raaijmakers
parent 8ca59e7c7e
commit bd56fdc57b
Notes: github-actions[bot] 2025-11-12 12:58:07 +00:00
3 changed files with 13 additions and 5 deletions

View file

@ -41,7 +41,7 @@ void HTMLSummaryElement::activation_behavior(DOM::Event const&)
}
// https://html.spec.whatwg.org/multipage/interactive-elements.html#summary-for-its-parent-details
bool HTMLSummaryElement::is_summary_for_its_parent_details()
bool HTMLSummaryElement::is_summary_for_its_parent_details() const
{
// A summary element is a summary for its parent details if the following algorithm returns true:
@ -64,6 +64,13 @@ bool HTMLSummaryElement::is_summary_for_its_parent_details()
return true;
}
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-summary-element
bool HTMLSummaryElement::is_focusable() const
{
// summary elements that are the first summary element child of a details element
return Base::is_focusable() || is_summary_for_its_parent_details();
}
HTMLSummaryElement::~HTMLSummaryElement() = default;
void HTMLSummaryElement::initialize(JS::Realm& realm)

View file

@ -21,10 +21,11 @@ public:
// https://www.w3.org/TR/html-aria/#el-details
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::button; }
bool is_summary_for_its_parent_details();
bool is_summary_for_its_parent_details() const;
virtual bool has_activation_behavior() const override;
virtual void activation_behavior(DOM::Event const&) override;
virtual bool is_focusable() const override;
private:
HTMLSummaryElement(DOM::Document&, DOM::QualifiedName);

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 35 tests
33 Pass
2 Fail
34 Pass
1 Fail
Pass a should not be focusable by default.
Pass a[href] should be focusable by default.
Pass button should be focusable by default.
@ -12,7 +12,7 @@ Pass input[type="button"] should be focusable by default.
Pass select should be focusable by default.
Pass textarea should be focusable by default.
Pass #summary-out should not be focusable by default.
Fail #summary-first should be focusable by default.
Pass #summary-first should be focusable by default.
Pass #summary-second should not be focusable by default.
Pass [contenteditable] should be focusable by default.
Pass iframe should be focusable by default.