LibWeb: Fix case insensitivity for HTMLElement "hidden" attribute

This commit is contained in:
Veeti Paananen 2025-09-10 21:02:12 +03:00 committed by Jelle Raaijmakers
commit 5e23df7d8a
Notes: github-actions[bot] 2025-09-11 13:21:48 +00:00
5 changed files with 111 additions and 2 deletions

View file

@ -852,13 +852,15 @@ GC::Ptr<DOM::NodeList> HTMLElement::labels()
return m_labels;
}
// https://html.spec.whatwg.org/multipage/interaction.html#dom-hidden
Variant<bool, double, String> HTMLElement::hidden() const
{
// 1. If the hidden attribute is in the hidden until found state, then return "until-found".
if (get_attribute(HTML::AttributeNames::hidden) == "until-found")
auto const& hidden = get_attribute(HTML::AttributeNames::hidden);
if (hidden.has_value() && hidden->equals_ignoring_ascii_case("until-found"sv))
return "until-found"_string;
// 2. If the hidden attribute is set, then return true.
if (has_attribute(HTML::AttributeNames::hidden))
if (hidden.has_value())
return true;
// 3. Return false.
return false;