Optimize Node::GetRootNode

This commit is contained in:
Fernando Jiménez Moreno 2019-03-08 08:01:09 +01:00
parent 8eba587547
commit 890297ef0a

View file

@ -2279,9 +2279,15 @@ impl NodeMethods for Node {
return shadow_root.Host().upcast::<Node>().GetRootNode(options);
}
}
self.inclusive_ancestors(ShadowIncluding::No)
.last()
.unwrap()
if let Some(shadow_root) = self.rare_data.owner_shadow_root.get() {
DomRoot::from_ref(shadow_root.upcast::<Node>())
} else if self.is_in_doc() {
DomRoot::from_ref(self.owner_doc().upcast::<Node>())
} else {
self.inclusive_ancestors(ShadowIncluding::No)
.last()
.unwrap()
}
}
// https://dom.spec.whatwg.org/#dom-node-parentnode