core/event.js
function _matchesSelector (element, selector, boundElement) {
  // no selector means this event was bound directly to this element
  if (selector === '_root') {
    return boundElement;
  }

  // if we have moved up to the element you bound the event to
  // then we have come too far
  if (element === boundElement) {
    return;
  }

  if (_getMatcher(element).call(element, selector)) {
    return element;
  }

  // if this element did not match but has a parent we should try
  // going up the tree to see if any of the parent elements match
  // for example if you are looking for a click on an <a> tag but there
  // is a <span> inside of the a tag that it is the target,
  // it should still work
  if (element.parentNode) {
    _level++;
    return _matchesSelector(element.parentNode, selector, boundElement);
  }
}
function _matchesSelector (element, selector, boundElement) {
  // no selector means this event was bound directly to this element
  if (selector === '_root') {
    return boundElement;
  }

  // if we have moved up to the element you bound the event to
  // then we have come too far
  if (element === boundElement) {
    return;
  }

  if (_getMatcher(element).call(element, selector)) {
    return element;
  }

  // if this element did not match but has a parent we should try
  // going up the tree to see if any of the parent elements match
  // for example if you are looking for a click on an <a> tag but there
  // is a <span> inside of the a tag that it is the target,
  // it should still work
  if (element.parentNode) {
    _level++;
    return _matchesSelector(element.parentNode, selector, boundElement);
  }
}
function _matchesSelector ( element , selector , boundElement ) { // no selector means this event was bound directly to this element if ( selector === '_root' ) { return boundElement ; } // if we have moved up to the element you bound the event to // then we have come too far if ( element === boundElement ) { return ; } if ( _getMatcher ( element ) . call ( element , selector ) ) { return element ; } // if this element did not match but has a parent we should try // going up the tree to see if any of the parent elements match // for example if you are looking for a click on an <a> tag but there // is a <span> inside of the a tag that it is the target, // it should still work if ( element . parentNode ) { _level ++ ; return _matchesSelector ( element . parentNode , selector , boundElement ) ; } }
determines if the specified element matches a given selector

@param {Node} element - the element to compare against the selector
@param {string} selector
@param {Node} boundElement - the element the listener was attached to
@returns {void|Node}
determines if the specified element matches a given selector