function getCommonAncestor()

in src/focus.service.ts [65:81]


function getCommonAncestor(
  nodeA: HTMLElement | null,
  nodeB: HTMLElement | null,
): HTMLElement | null {
  if (nodeA === null || nodeB === null) {
    return null;
  }

  const mask = 0x10;
  while (nodeA != null && (nodeA = nodeA.parentElement)) {
    // tslint:disable-next-line
    if ((nodeA.compareDocumentPosition(nodeB) & mask) === mask) {
      return nodeA;
    }
  }
  return null;
}