docs: function closest(element, selector) {
      var closest;
  
      while (!closest) {
          if (matches(element, selector)) {
              closest = element;
          }
  
          element = parent(element);
  
          if (!element || element === document) {
              break;
          }
      }
  
      return closest;
  }