mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
improvement: body element check (#37442)
Created a new method `HTMLElement::is_body_element` that replaces `HTMLBodyElement::is_the_html_body_element`. Testing: Existing WPT tests should pass. Fixes: https://github.com/servo/servo/issues/37429 --------- Signed-off-by: iamlockon <xdddxyyyxzzz123@gmail.com>
This commit is contained in:
parent
c74a422e4c
commit
96adb1e959
4 changed files with 24 additions and 28 deletions
|
@ -55,17 +55,6 @@ impl HTMLBodyElement {
|
|||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/cssom-view/#the-html-body-element>
|
||||
pub(crate) fn is_the_html_body_element(&self) -> bool {
|
||||
let self_node = self.upcast::<Node>();
|
||||
let root_elem = self.upcast::<Element>().root_element();
|
||||
let root_node = root_elem.upcast::<Node>();
|
||||
root_node.is_parent_of(self_node) &&
|
||||
self_node
|
||||
.preceding_siblings()
|
||||
.all(|n| !n.is::<HTMLBodyElement>())
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLBodyElementMethods<crate::DomTypeHolder> for HTMLBodyElement {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue