mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-25 20:22:18 +03: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: https://github.com/SerenityOS/serenity/commit/0c76c7ee36 Pull-request: https://github.com/SerenityOS/serenity/pull/23572 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/trflynn89
@ -777,7 +777,8 @@ bool Element::is_target() const
|
|||||||
// https://dom.spec.whatwg.org/#document-element
|
// https://dom.spec.whatwg.org/#document-element
|
||||||
bool Element::is_document_element() const
|
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)
|
JS::NonnullGCPtr<HTMLCollection> Element::get_elements_by_class_name(StringView class_names)
|
||||||
|
Loading…
Reference in New Issue
Block a user