mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +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
Notes:
sideshowbarker
2024-07-17 10:05:47 +09:00
Author: https://github.com/awesomekling
Commit: 0c76c7ee36
Pull-request: https://github.com/SerenityOS/serenity/pull/23572
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/trflynn89
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