Retarget result of shadowRoot.element(s)FromPoint

This commit is contained in:
Fernando Jiménez Moreno 2019-02-14 18:19:06 +01:00
parent 8641866a50
commit 07e2f41c34
3 changed files with 30 additions and 10 deletions

View file

@ -1123,14 +1123,16 @@ impl Node {
}
/// https://dom.spec.whatwg.org/#retarget
pub fn retarget(&self, a: &Node, b: &Node) -> DomRoot<Node> {
let mut a = DomRoot::from_ref(&*a);
pub fn retarget(&self, b: &Node) -> DomRoot<Node> {
let mut a = DomRoot::from_ref(&*self);
loop {
// Step 1.
let a_root = a.GetRootNode(&GetRootNodeOptions::empty());
if !a_root.is::<ShadowRoot>() || a_root.is_shadow_including_inclusive_ancestor_of(b) {
return DomRoot::from_ref(&a);
}
// Step 2.
a = DomRoot::from_ref(
a_root
.downcast::<ShadowRoot>()