LibWeb: Derive implicit aria-level for h1–h6 from tag name

This commit is contained in:
Dowsley 2025-10-10 08:25:49 -07:00 committed by Sam Atkins
parent d7f830cdd1
commit c6b289c3dc
Notes: github-actions[bot] 2025-10-10 16:19:11 +00:00
6 changed files with 40 additions and 2 deletions

View file

@ -26,8 +26,11 @@ public:
virtual Optional<String> aria_level() const override
{
// TODO: aria-level = the number in the element's tag name
return get_attribute("aria-level"_fly_string);
if (auto const attr = get_attribute(ARIA::AttributeNames::aria_level); attr.has_value())
return attr;
// Implicit defaults to the number in the element's tag name.
return MUST(local_name().to_string().substring_from_byte_offset(1));
}
private: