mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 02:44:58 +00:00
LibWeb: Make Element::is_document_element() slightly nicer
By following the spec more closely, we can actually make this function a bit more efficient (by comparing the parent against the document instead of looking for the first element child of the document).
This commit is contained in:
parent
bbf67faa95
commit
0c76c7ee36
1 changed files with 2 additions and 1 deletions
|
@ -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<HTMLCollection> Element::get_elements_by_class_name(StringView class_names)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue