function retarget(a, b) {
  while (true) {
    if (!isNode(a)) {
      return a;
    }

    const aRoot = getRoot(a);
    if (
      !isShadowRoot(aRoot) ||
      (isNode(b) && isShadowInclusiveAncestor(aRoot, b))
    ) {
      return a;
    }

    a = getRoot(a).host;
  }
}
function retarget(a, b) {
  while (true) {
    if (!isNode(a)) {
      return a;
    }

    const aRoot = getRoot(a);
    if (
      !isShadowRoot(aRoot) ||
      (isNode(b) && isShadowInclusiveAncestor(aRoot, b))
    ) {
      return a;
    }

    a = getRoot(a).host;
  }
}
function retarget ( a , b ) { while ( true ) { if ( ! isNode ( a ) ) { return a ; } const aRoot = getRoot ( a ) ; if ( ! isShadowRoot ( aRoot ) || ( isNode ( b ) && isShadowInclusiveAncestor ( aRoot , b ) ) ) { return a ; } a = getRoot ( a ) . host ; } }
https://dom.spec.whatwg.org/#retarget
https : // dom . spec . whatwg . org / #retarget