mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Optimize Node::GetRootNode
This commit is contained in:
parent
8eba587547
commit
890297ef0a
1 changed files with 9 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue