Skip to content
Permalink
Browse files

Optimize Node::GetRootNode

  • Loading branch information...
ferjm committed Mar 8, 2019
1 parent 8eba587 commit 890297ef0a448edbe074e23fb98f2b6054c03e0e
Showing with 9 additions and 3 deletions.
  1. +9 −3 components/script/dom/node.rs
@@ -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

0 comments on commit 890297e

Please sign in to comment.
You can’t perform that action at this time.