diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index e788808dae7a..b07b546cd6b1 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -1394,10 +1395,12 @@ void Document::set_hovered_node(Node* node) } } -JS::NonnullGCPtr Document::get_elements_by_name(FlyString const& name) +JS::NonnullGCPtr Document::get_elements_by_name(FlyString const& name) { - return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [name](Element const& element) { - return element.name() == name; + return LiveNodeList::create(realm(), *this, LiveNodeList::Scope::Descendants, [name](auto const& node) { + if (!is(node)) + return false; + return verify_cast(node).name() == name; }); } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 9c994b346da5..1d8d2a578c50 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -248,7 +248,7 @@ class Document void schedule_style_update(); void schedule_layout_update(); - JS::NonnullGCPtr get_elements_by_name(FlyString const&); + JS::NonnullGCPtr get_elements_by_name(FlyString const&); JS::NonnullGCPtr applets(); JS::NonnullGCPtr anchors(); diff --git a/Userland/Libraries/LibWeb/DOM/Document.idl b/Userland/Libraries/LibWeb/DOM/Document.idl index 34d0dd662658..3ee2e8aa4ea9 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.idl +++ b/Userland/Libraries/LibWeb/DOM/Document.idl @@ -73,7 +73,7 @@ interface Document : Node { readonly attribute Element? activeElement; Element? getElementById(DOMString id); - HTMLCollection getElementsByName([FlyString] DOMString name); + NodeList getElementsByName([FlyString] DOMString name); HTMLCollection getElementsByTagName([FlyString] DOMString tagName); HTMLCollection getElementsByTagNameNS([FlyString] DOMString? namespace, [FlyString] DOMString localName); HTMLCollection getElementsByClassName(DOMString className);