function adjacent(node, selector, ancestry, side) {
    const parent = ancestry[0];
    if (!parent) {
      return false;
    }
    const keys = Object.keys(parent);
    for (let i = 0; i < keys.length; ++i) {
      const listProp = parent[keys[i]];
      if (Array.isArray(listProp)) {
        const idx = listProp.indexOf(node);
        if (idx < 0) {
          continue;
        }
        if (
          side === LEFT_SIDE &&
          idx > 0 &&
          matches(listProp[idx - 1], selector, ancestry)
        ) {
          return true;
        }
        if (
          side === RIGHT_SIDE &&
          idx < listProp.length - 1 &&
          matches(listProp[idx + 1], selector, ancestry)
        ) {
          return true;
        }
      }
    }
    return false;
  }
/*
   * Determines if the given node has an asjacent sibling that matches the given selector.
   */
Determines if the given node has an asjacent sibling that matches the given selector.
Determines if the given node has an asjacent sibling that matches the given selector .
function adjacent(node, selector, ancestry, side) {
    const parent = ancestry[0];
    if (!parent) {
      return false;
    }
    const keys = Object.keys(parent);
    for (let i = 0; i < keys.length; ++i) {
      const listProp = parent[keys[i]];
      if (Array.isArray(listProp)) {
        const idx = listProp.indexOf(node);
        if (idx < 0) {
          continue;
        }
        if (
          side === LEFT_SIDE &&
          idx > 0 &&
          matches(listProp[idx - 1], selector, ancestry)
        ) {
          return true;
        }
        if (
          side === RIGHT_SIDE &&
          idx < listProp.length - 1 &&
          matches(listProp[idx + 1], selector, ancestry)
        ) {
          return true;
        }
      }
    }
    return false;
  }
function adjacent ( node , selector , ancestry , side ) { const parent = ancestry [ 0 ] ; if ( ! parent ) { return false ; } const keys = Object . keys ( parent ) ; for ( let i = 0 ; i < keys . length ; ++ i ) { const listProp = parent [ keys [ i ] ] ; if ( Array . isArray ( listProp ) ) { const idx = listProp . indexOf ( node ) ; if ( idx < 0 ) { continue ; } if ( side === LEFT_SIDE && idx > 0 && matches ( listProp [ idx - 1 ] , selector , ancestry ) ) { return true ; } if ( side === RIGHT_SIDE && idx < listProp . length - 1 && matches ( listProp [ idx + 1 ] , selector , ancestry ) ) { return true ; } } } return false ; }
Determines if the given node has an asjacent sibling that matches the given selector.
Determines if the given node has an asjacent sibling that matches the given selector .