nl_tokens: Add an event listener to element It stores the handler function in a separate cache object and adds a generic handler to the element s event along with a unique id ( guid ) to the element .
pl_tokens: function on ( elem , <mask> , fn ) { if ( Array . isArray ( type ) ) { return _handleMultipleEvents ( on , elem , type , fn ) ; } var data = getData ( elem ) ; // We need a place to store all our handler data if ( ! data . handlers ) { data . handlers = { } ; } if ( ! data . handlers [ type ] ) { data . handlers [ type ] = [ ] ; } if ( ! fn . guid ) { fn . guid = newGUID ( ) ; } data . handlers [ type ] . push ( fn ) ; if ( ! data . dispatcher ) { data . disabled = false ; data . dispatcher = function ( event , hash ) { if ( data . disabled ) { return ; } event = fixEvent ( event ) ; var handlers = data . handlers [ event . type ] ; if ( handlers ) { // Copy handlers so if handlers are added/removed during the process it doesn't throw everything off. var handlersCopy = handlers . slice ( 0 ) ; for ( var m = 0 , n = handlersCopy . length ; m < n ; m ++ ) { if ( event . isImmediatePropagationStopped ( ) ) { break ; } else { try { handlersCopy [ m ] . call ( elem , event , hash ) ; } catch ( e ) { log$1 . error ( e ) ; } } } } } ; } if ( data . handlers [ type ] . length === 1 ) { if ( elem . addEventListener ) { var options = false ; if ( _supportsPassive && passiveEvents . indexOf ( type ) > - 1 ) { options = { passive : true } ; } elem . addEventListener ( type , data . dispatcher , options ) ; } else if ( elem . attachEvent ) { elem . attachEvent ( 'on' + type , data . dispatcher ) ; } } }