packages/js-toolkit/abstracts/Base/events.js
/**
 * Bind event handler methods to the root HTML element.
 *
 * @param  {Base}  instance     A Base instance.
 * @param  {Array} eventMethods A list of methods to bind.
 * @return {Array}              A list of unbind functions.
 */
Bind event handler methods to the root HTML element.
@param  {Base}  instance     A Base instance.
@param  {Array} eventMethods A list of methods to bind.
@return {Array}              A list of unbind functions.
Bind event handler methods to the root HTML element . @param { Base } instance A Base instance . @param { Array } eventMethods A list of methods to bind . @return { Array } A list of unbind functions .
function bindRootEvents(instance, eventMethods) {
  return eventMethods.map((eventMethod) => {
    const eventName = eventMethod.replace(/^on/, '').toLowerCase();
    const handler = (...args) => {
      if (__DEV__) {
        debug(instance, eventMethod, instance.$el, ...args);
      }
      instance[eventMethod](...args);
    };
    instance.$el.addEventListener(eventName, handler);
    return () => {
      instance.$el.removeEventListener(eventName, handler);
    };
  });
}
function bindRootEvents ( instance , eventMethods ) { return eventMethods . map ( ( eventMethod ) => { const eventName = eventMethod . replace ( / ^on / , '' ) . toLowerCase ( ) ; const handler = ( ... args ) => { if ( __DEV__ ) { debug ( instance , eventMethod , instance . $el , ... args ) ; } instance [ eventMethod ] ( ... args ) ; } ; instance . $el . addEventListener ( eventName , handler ) ; return ( ) => { instance . $el . removeEventListener ( eventName , handler ) ; } ; } ) ; }
Bind event handler methods to the root HTML element.
Bind event handler methods to the root HTML element .