core/event.js
function _bind (events, selector, callback, remove) {
  // fail silently if you pass null or undefined as an alement
  // in the Delegator constructor
  if (!this.element) {
    return;
  }

  if (!(events instanceof Array)) {
    events = [events];
  }

  if (!callback && typeof (selector) === 'function') {
    callback = selector;
    selector = '_root';
  }

  if (selector instanceof window.Element) {
    let id;
    if (selector.hasAttribute('bind-event-id')) {
      id = selector.getAttribute('bind-event-id');
    } else {
      id = nextEventId();
      selector.setAttribute('bind-event-id', id);
    }
    selector = `[bind-event-id="${id}"]`;
  }

  let id = this.id;
  let i;

  function _getGlobalCallback (type) {
    return function (e) {
      _handleEvent(id, e, type);
    };
  }

  for (i = 0; i < events.length; i++) {
    _aliases(events[i]).forEach(alias => {
      if (remove) {
        _removeHandler(this, alias, selector, callback);
        return;
      }

      if (!_handlers[id] || !_handlers[id][alias]) {
        Delegator.addEvent(this, alias, _getGlobalCallback(alias));
      }

      _addHandler(this, alias, selector, callback);
    });
  }

  return this;
}
function _bind (events, selector, callback, remove) {
  // fail silently if you pass null or undefined as an alement
  // in the Delegator constructor
  if (!this.element) {
    return;
  }

  if (!(events instanceof Array)) {
    events = [events];
  }

  if (!callback && typeof (selector) === 'function') {
    callback = selector;
    selector = '_root';
  }

  if (selector instanceof window.Element) {
    let id;
    if (selector.hasAttribute('bind-event-id')) {
      id = selector.getAttribute('bind-event-id');
    } else {
      id = nextEventId();
      selector.setAttribute('bind-event-id', id);
    }
    selector = `[bind-event-id="${id}"]`;
  }

  let id = this.id;
  let i;

  function _getGlobalCallback (type) {
    return function (e) {
      _handleEvent(id, e, type);
    };
  }

  for (i = 0; i < events.length; i++) {
    _aliases(events[i]).forEach(alias => {
      if (remove) {
        _removeHandler(this, alias, selector, callback);
        return;
      }

      if (!_handlers[id] || !_handlers[id][alias]) {
        Delegator.addEvent(this, alias, _getGlobalCallback(alias));
      }

      _addHandler(this, alias, selector, callback);
    });
  }

  return this;
}
function _bind ( events , selector , callback , remove ) { // fail silently if you pass null or undefined as an alement // in the Delegator constructor if ( ! this . element ) { return ; } if ( ! ( events instanceof Array ) ) { events = [ events ] ; } if ( ! callback && typeof ( selector ) === 'function' ) { callback = selector ; selector = '_root' ; } if ( selector instanceof window . Element ) { let id ; if ( selector . hasAttribute ( 'bind-event-id' ) ) { id = selector . getAttribute ( 'bind-event-id' ) ; } else { id = nextEventId ( ) ; selector . setAttribute ( 'bind-event-id' , id ) ; } selector = ` ${ id } ` ; } let id = this . id ; let i ; function _getGlobalCallback ( type ) { return function ( e ) { _handleEvent ( id , e , type ) ; } ; } for ( i = 0 ; i < events . length ; i ++ ) { _aliases ( events [ i ] ) . forEach ( alias => { if ( remove ) { _removeHandler ( this , alias , selector , callback ) ; return ; } if ( ! _handlers [ id ] || ! _handlers [ id ] [ alias ] ) { Delegator . addEvent ( this , alias , _getGlobalCallback ( alias ) ) ; } _addHandler ( this , alias , selector , callback ) ; } ) ; } return this ; }
binds the specified events to the element

@param {string|Array} events
@param {string} selector
@param {Function} callback
@param {boolean=} remove
@returns {Object}
binds the specified events to the element