mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 09:58:14 +00:00
LibWeb: Add the Document.documentElement API
Also change DOM::Document::document_element() to return an Element* and not an HTML::HTMLHtmlElement since that's not the only kind of documentElement we might encounter.
This commit is contained in:
parent
64a82100bd
commit
e27726dc92
4 changed files with 12 additions and 3 deletions
|
@ -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<HTML::HTMLHtmlElement>();
|
||||
return first_child_of_type<Element>();
|
||||
}
|
||||
|
||||
const HTML::HTMLHeadElement* Document::head() const
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ interface Document : Node {
|
|||
readonly attribute DOMString compatMode;
|
||||
readonly attribute DocumentType? doctype;
|
||||
|
||||
readonly attribute Element? documentElement;
|
||||
readonly attribute HTMLElement? body;
|
||||
|
||||
}
|
||||
|
|
8
Libraries/LibWeb/Tests/Document/documentElement.js
Normal file
8
Libraries/LibWeb/Tests/Document/documentElement.js
Normal file
|
@ -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");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue