diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 26ac8b0f86e..4b04d89bcfa 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -777,7 +777,8 @@ bool Element::is_target() const // https://dom.spec.whatwg.org/#document-element bool Element::is_document_element() const { - return document().document_element() == this; + // The document element of a document is the element whose parent is that document, if it exists; otherwise null. + return parent() == &document(); } JS::NonnullGCPtr Element::get_elements_by_class_name(StringView class_names)