diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp index 55df08802c2..499b4468a6a 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -852,13 +852,15 @@ GC::Ptr HTMLElement::labels() return m_labels; } +// https://html.spec.whatwg.org/multipage/interaction.html#dom-hidden Variant 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; diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/editing/the-hidden-attribute/hidden-ua-stylesheet.txt b/Tests/LibWeb/Text/expected/wpt-import/html/editing/the-hidden-attribute/hidden-ua-stylesheet.txt new file mode 100644 index 00000000000..dde9413ee0d --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/editing/the-hidden-attribute/hidden-ua-stylesheet.txt @@ -0,0 +1,13 @@ +Harness status: OK + +Found 8 tests + +8 Pass +Pass hidden-ua-stylesheet +Pass div.removeAttribute('hidden') +Pass div.setAttribute('hidden', '') +Pass div.setAttribute('hidden', 'asdf') +Pass div.setAttribute('hidden', 'until-found') +Pass div.setAttribute('hidden', 'UNTIL-FOUND') +Pass div.setAttribute('hidden', 'UnTiL-FoUnD') +Pass div.setAttribute('hidden', '0') \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/editing/the-hidden-attribute/hidden-until-found-idl.txt b/Tests/LibWeb/Text/expected/wpt-import/html/editing/the-hidden-attribute/hidden-until-found-idl.txt new file mode 100644 index 00000000000..f0f6a0e9cdc --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/editing/the-hidden-attribute/hidden-until-found-idl.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass element.hidden should return "until-found" regardless of uppercase letters. \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/html/editing/the-hidden-attribute/hidden-ua-stylesheet.html b/Tests/LibWeb/Text/input/wpt-import/html/editing/the-hidden-attribute/hidden-ua-stylesheet.html new file mode 100644 index 00000000000..a7bddc3f727 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/editing/the-hidden-attribute/hidden-ua-stylesheet.html @@ -0,0 +1,68 @@ + + + + + + + +
hello world
+ + + + +
+ + diff --git a/Tests/LibWeb/Text/input/wpt-import/html/editing/the-hidden-attribute/hidden-until-found-idl.html b/Tests/LibWeb/Text/input/wpt-import/html/editing/the-hidden-attribute/hidden-until-found-idl.html new file mode 100644 index 00000000000..5df0b767fd6 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/editing/the-hidden-attribute/hidden-until-found-idl.html @@ -0,0 +1,20 @@ + + + + + + + +
div
+ +