diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 5f6a29fdd6..34ea160b00 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -127,9 +127,9 @@ void Document::fixup() this->append_child(html); } -const HTML::HTMLHtmlElement* Document::document_element() const +const Element* Document::document_element() const { - return first_child_of_type(); + return first_child_of_type(); } const HTML::HTMLHeadElement* Document::head() const diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index 6997e1b493..5bdac924b7 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -85,7 +85,7 @@ public: Node* inspected_node() { return m_inspected_node; } const Node* inspected_node() const { return m_inspected_node; } - const HTML::HTMLHtmlElement* document_element() const; + const Element* document_element() const; const HTML::HTMLHeadElement* head() const; const HTML::HTMLElement* body() const; diff --git a/Libraries/LibWeb/DOM/Document.idl b/Libraries/LibWeb/DOM/Document.idl index 9d1184115b..f2cbf8eafa 100644 --- a/Libraries/LibWeb/DOM/Document.idl +++ b/Libraries/LibWeb/DOM/Document.idl @@ -9,6 +9,7 @@ interface Document : Node { readonly attribute DOMString compatMode; readonly attribute DocumentType? doctype; + readonly attribute Element? documentElement; readonly attribute HTMLElement? body; } diff --git a/Libraries/LibWeb/Tests/Document/documentElement.js b/Libraries/LibWeb/Tests/Document/documentElement.js new file mode 100644 index 0000000000..a9b084e78e --- /dev/null +++ b/Libraries/LibWeb/Tests/Document/documentElement.js @@ -0,0 +1,8 @@ +loadPage("file:///res/html/misc/blank.html"); + +afterInitialPageLoad(() => { + test("Basic functionality", () => { + expect(document.documentElement).not.toBe(null); + expect(document.documentElement.nodeName).toBe("html"); + }); +});