export default function closest(el, selector) {
  if (el.closest) {
    return el.closest(selector);
  }

  var matchesSelector = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;

  while (el) {
    if (matchesSelector.call(el, selector)) {
      return el;
    }

    el = el.parentElement;
  }

  return null;
}