aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlbodyelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmlbodyelement.rs')
-rw-r--r--components/script/dom/htmlbodyelement.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index 8ac184ea51d..ca133b88dbb 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -47,6 +47,16 @@ impl HTMLBodyElement {
let element = HTMLBodyElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBodyElementBinding::Wrap)
}
+
+ /// https://drafts.csswg.org/cssom-view/#the-html-body-element
+ pub 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 for HTMLBodyElement {