LibWeb: Assign ARIA role “switch” to <input type=checkbox switch>

This commit is contained in:
sideshowbarker 2024-12-09 16:31:18 +09:00 committed by Jelle Raaijmakers
parent 18132a0be1
commit 0a2aa87107
Notes: github-actions[bot] 2024-12-09 08:48:26 +00:00
3 changed files with 73 additions and 1 deletions

View file

@ -2355,8 +2355,12 @@ Optional<ARIA::Role> HTMLInputElement::default_role() const
if (type_state() == TypeAttributeState::Button)
return ARIA::Role::button;
// https://www.w3.org/TR/html-aria/#el-input-checkbox
if (type_state() == TypeAttributeState::Checkbox)
if (type_state() == TypeAttributeState::Checkbox) {
// https://github.com/w3c/html-aam/issues/496
if (has_attribute("switch"_string))
return ARIA::Role::switch_;
return ARIA::Role::checkbox;
}
// https://www.w3.org/TR/html-aria/#el-input-email
if (type_state() == TypeAttributeState::Email && !has_attribute(AttributeNames::list))
return ARIA::Role::textbox;