diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 7d2e50794ed..e788808dae7 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1401,21 +1401,6 @@ JS::NonnullGCPtr Document::get_elements_by_name(FlyString const& }); } -JS::NonnullGCPtr Document::get_elements_by_class_name(StringView class_names) -{ - Vector list_of_class_names; - for (auto& name : class_names.split_view(' ')) { - list_of_class_names.append(FlyString::from_utf8(name).release_value_but_fixme_should_propagate_errors()); - } - return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) { - for (auto& name : list_of_class_names) { - if (!element.has_class(name, quirks_mode ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive)) - return false; - } - return true; - }); -} - // https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-applets JS::NonnullGCPtr Document::applets() { diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 3d780a12915..9c994b346da 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -249,7 +249,6 @@ public: void schedule_layout_update(); JS::NonnullGCPtr get_elements_by_name(FlyString const&); - JS::NonnullGCPtr get_elements_by_class_name(StringView); JS::NonnullGCPtr applets(); JS::NonnullGCPtr anchors(); diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index a27910e523d..85be7b80e48 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -814,21 +814,6 @@ bool Element::is_document_element() const return parent() == &document(); } -JS::NonnullGCPtr Element::get_elements_by_class_name(StringView class_names) -{ - Vector list_of_class_names; - for (auto& name : class_names.split_view_if(Infra::is_ascii_whitespace)) { - list_of_class_names.append(FlyString::from_utf8(name).release_value_but_fixme_should_propagate_errors()); - } - return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) { - for (auto& name : list_of_class_names) { - if (!element.has_class(name, quirks_mode ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive)) - return false; - } - return true; - }); -} - // https://dom.spec.whatwg.org/#element-shadow-host bool Element::is_shadow_host() const { diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index e546feb2d21..014304f8f30 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -212,8 +212,6 @@ public: bool is_target() const; bool is_document_element() const; - JS::NonnullGCPtr get_elements_by_class_name(StringView); - bool is_shadow_host() const; JS::GCPtr shadow_root() { return m_shadow_root; } JS::GCPtr shadow_root() const { return m_shadow_root; } diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp index f32a8b7d271..28ec79d6bd5 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -225,4 +226,19 @@ WebIDL::ExceptionOr ParentNode::replace_children(Vector ParentNode::get_elements_by_class_name(StringView class_names) +{ + Vector list_of_class_names; + for (auto& name : class_names.split_view_if(Infra::is_ascii_whitespace)) { + list_of_class_names.append(FlyString::from_utf8(name).release_value_but_fixme_should_propagate_errors()); + } + return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) { + for (auto& name : list_of_class_names) { + if (!element.has_class(name, quirks_mode ? CaseSensitivity::CaseInsensitive : CaseSensitivity::CaseSensitive)) + return false; + } + return true; + }); +} + } diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.h b/Userland/Libraries/LibWeb/DOM/ParentNode.h index 184f1d93116..40fe7c7ce32 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.h +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.h @@ -36,6 +36,8 @@ public: WebIDL::ExceptionOr append(Vector, String>> const& nodes); WebIDL::ExceptionOr replace_children(Vector, String>> const& nodes); + JS::NonnullGCPtr get_elements_by_class_name(StringView); + protected: ParentNode(JS::Realm& realm, Document& document, NodeType type) : Node(realm, document, type)