diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index b63c6a5e8d8..5911c1b3651 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -454,6 +454,22 @@ private: template<> inline bool Node::fast_is() const { return is_element(); } +inline Element* Node::parent_element() +{ + auto* parent = this->parent(); + if (!parent || !is(parent)) + return nullptr; + return static_cast(parent); +} + +inline Element const* Node::parent_element() const +{ + auto const* parent = this->parent(); + if (!parent || !is(parent)) + return nullptr; + return static_cast(parent); +} + WebIDL::ExceptionOr validate_and_extract(JS::Realm&, Optional namespace_, FlyString const& qualified_name); } diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index a421847411f..7a4c896f5f5 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -330,20 +330,6 @@ bool Node::is_connected() const return shadow_including_root().is_document(); } -Element* Node::parent_element() -{ - if (!parent() || !is(parent())) - return nullptr; - return verify_cast(parent()); -} - -Element const* Node::parent_element() const -{ - if (!parent() || !is(parent())) - return nullptr; - return verify_cast(parent()); -} - // https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity WebIDL::ExceptionOr Node::ensure_pre_insertion_validity(JS::NonnullGCPtr node, JS::GCPtr child) const {