mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibWeb: Add spec comments to a couple of Document element getters
The implementations are correct as-is. The spec comments are mostly to help point out that an upcoming getter (the title element) is currently accessed incorrectly. It is currently implemented like the head element and searches the "expected" parent head element for its first title element; instead it should search the document itself. This incorrect behavior becomes clearer if all of these elements have spec comments.
This commit is contained in:
parent
efd8176ce3
commit
e8fde316f6
1 changed files with 5 additions and 0 deletions
|
@ -610,16 +610,21 @@ Element const* Document::document_element() const
|
|||
return first_child_of_type<Element>();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#the-html-element-2
|
||||
HTML::HTMLHtmlElement* Document::html_element()
|
||||
{
|
||||
// The html element of a document is its document element, if it's an html element, and null otherwise.
|
||||
auto* html = document_element();
|
||||
if (is<HTML::HTMLHtmlElement>(html))
|
||||
return verify_cast<HTML::HTMLHtmlElement>(html);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#the-head-element-2
|
||||
HTML::HTMLHeadElement* Document::head()
|
||||
{
|
||||
// The head element of a document is the first head element that is a child of the html element, if there is one,
|
||||
// or null otherwise.
|
||||
auto* html = html_element();
|
||||
if (!html)
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue