index.js
function matches(node, selector) {
  var parent, matches, i;

  if (node.matches) {
    return node.matches(selector);
  } else {
    parent = node.parentElement;
    matches = parent ? parent.querySelectorAll(selector) : [];
    i = 0;
    while (matches[i] && matches[i] !== node) {
      i++;
    }
    return !!matches[i];
  }
}
function matches(node, selector) {
  var parent, matches, i;

  if (node.matches) {
    return node.matches(selector);
  } else {
    parent = node.parentElement;
    matches = parent ? parent.querySelectorAll(selector) : [];
    i = 0;
    while (matches[i] && matches[i] !== node) {
      i++;
    }
    return !!matches[i];
  }
}
function matches ( node , selector ) { var parent , matches , i ; if ( node . matches ) { return node . matches ( selector ) ; } else { parent = node . parentElement ; matches = parent ? parent . querySelectorAll ( selector ) : [ ] ; i = 0 ; while ( matches [ i ] && matches [ i ] !== node ) { i ++ ; } return ! ! matches [ i ] ; } }
Returns true if the element would be selected by the specified selector.
Essentially a polyfill, but necessary for `closest`.
@param {Node} node   preferably an Element for better performance, but it will accept any Node.
@param {string} selector
@returns {boolean}
Returns true if the element would be selected by the specified selector . Essentially a polyfill but necessary for closest .