diff --git a/Tests/LibWeb/Text/expected/DOM/Document-getElementsByName-returns-html-elements.txt b/Tests/LibWeb/Text/expected/DOM/Document-getElementsByName-returns-html-elements.txt new file mode 100644 index 00000000000..edddd76b7c9 --- /dev/null +++ b/Tests/LibWeb/Text/expected/DOM/Document-getElementsByName-returns-html-elements.txt @@ -0,0 +1,4 @@ +1 == 1 +P == P +1 == 1 +P == P diff --git a/Tests/LibWeb/Text/input/DOM/Document-getElementsByName-returns-html-elements.html b/Tests/LibWeb/Text/input/DOM/Document-getElementsByName-returns-html-elements.html new file mode 100644 index 00000000000..09e414f298d --- /dev/null +++ b/Tests/LibWeb/Text/input/DOM/Document-getElementsByName-returns-html-elements.html @@ -0,0 +1,18 @@ + +

+a ++ +b + +

+ + + + diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index e19ed7d6b85..45bfa69e60a 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1488,12 +1488,13 @@ void Document::set_hovered_node(Node* node) } } +// https://html.spec.whatwg.org/multipage/dom.html#dom-document-getelementsbyname JS::NonnullGCPtr Document::get_elements_by_name(FlyString const& name) { return LiveNodeList::create(realm(), *this, LiveNodeList::Scope::Descendants, [name](auto const& node) { - if (!is(node)) + if (!is(node)) return false; - return verify_cast(node).name() == name; + return verify_cast(node).name() == name; }); }