mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Fix input@type=button|submit|reset accessible-name computation
This change makes Ladybird conform to the requirements in the HTML-AAM spec at https://w3c.github.io/html-aam/#accname-computation for the cases of HTML input@type=button, input@type=submit, and input@type=reset elements. Otherwise, without this change, Ladybird fails to expose the expected accessible names for those cases.
This commit is contained in:
parent
6ee54ca08a
commit
032396ba4d
1 changed files with 7 additions and 0 deletions
|
@ -2383,6 +2383,13 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
|||
if (is<HTML::HTMLInputElement>(*element)) {
|
||||
auto& input = (const_cast<HTML::HTMLInputElement&>(static_cast<HTML::HTMLInputElement const&>(*element)));
|
||||
// https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation
|
||||
// Otherwise use the value attribute.
|
||||
if (input.type_state() == HTML::HTMLInputElement::TypeAttributeState::Button
|
||||
|| input.type_state() == HTML::HTMLInputElement::TypeAttributeState::SubmitButton
|
||||
|| input.type_state() == HTML::HTMLInputElement::TypeAttributeState::ResetButton)
|
||||
if (auto value = input.get_attribute(HTML::AttributeNames::value); value.has_value())
|
||||
return value.value();
|
||||
// https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation
|
||||
// Otherwise use alt attribute if present and its value is not the empty string.
|
||||
if (input.type_state() == HTML::HTMLInputElement::TypeAttributeState::ImageButton)
|
||||
if (auto alt = element->get_attribute(HTML::AttributeNames::alt); alt.has_value())
|
||||
|
|
Loading…
Reference in a new issue