src/event-listener.js
function(eventName, selector, callback) {
        if (!isString(eventName)) {
            var eventsMap = eventName;
            for (var key in eventsMap) {
                if (eventsMap.hasOwnProperty(key)) {
                    var split = key.split(' ');
                    if (split.length > 1) {
                        this.on(split[0], split[1], eventsMap[key]);
                    } else {
                        this.on(split[0], eventsMap[key]);
                    }
                }
            }
            return;
        }

        if (!isString(selector)) {
            callback = selector;
            selector = '';
        }

        if (!this.events.hasOwnProperty(eventName)) {
            var useCapture = CAPTURED_EVENTS.indexOf(eventName) > -1;
            this.el.addEventListener(eventName, this._onEvent, useCapture);

            this.events[eventName] = {};
        }

        if (!this.events[eventName].hasOwnProperty(selector)) {
            this.events[eventName][selector] = [];
        }

        if (this.events[eventName][selector].indexOf(callback) < 0) {
            this.events[eventName][selector].push(callback);
        }
    }
function(eventName, selector, callback) {
        if (!isString(eventName)) {
            var eventsMap = eventName;
            for (var key in eventsMap) {
                if (eventsMap.hasOwnProperty(key)) {
                    var split = key.split(' ');
                    if (split.length > 1) {
                        this.on(split[0], split[1], eventsMap[key]);
                    } else {
                        this.on(split[0], eventsMap[key]);
                    }
                }
            }
            return;
        }

        if (!isString(selector)) {
            callback = selector;
            selector = '';
        }

        if (!this.events.hasOwnProperty(eventName)) {
            var useCapture = CAPTURED_EVENTS.indexOf(eventName) > -1;
            this.el.addEventListener(eventName, this._onEvent, useCapture);

            this.events[eventName] = {};
        }

        if (!this.events[eventName].hasOwnProperty(selector)) {
            this.events[eventName][selector] = [];
        }

        if (this.events[eventName][selector].indexOf(callback) < 0) {
            this.events[eventName][selector].push(callback);
        }
    }
function ( eventName , selector , callback ) { if ( ! isString ( eventName ) ) { var eventsMap = eventName ; for ( var key in eventsMap ) { if ( eventsMap . hasOwnProperty ( key ) ) { var split = key . split ( ' ' ) ; if ( split . length > 1 ) { this . on ( split [ 0 ] , split [ 1 ] , eventsMap [ key ] ) ; } else { this . on ( split [ 0 ] , eventsMap [ key ] ) ; } } } return ; } if ( ! isString ( selector ) ) { callback = selector ; selector = '' ; } if ( ! this . events . hasOwnProperty ( eventName ) ) { var useCapture = CAPTURED_EVENTS . indexOf ( eventName ) > - 1 ; this . el . addEventListener ( eventName , this . _onEvent , useCapture ) ; this . events [ eventName ] = { } ; } if ( ! this . events [ eventName ] . hasOwnProperty ( selector ) ) { this . events [ eventName ] [ selector ] = [ ] ; } if ( this . events [ eventName ] [ selector ] . indexOf ( callback ) < 0 ) { this . events [ eventName ] [ selector ] . push ( callback ) ; } }
Starts listening to an event.

@param eventName Name of the event to listen to, in lower-case.
@param selector Optional CSS selector. If given, only events inside a child element matching
the selector are caught.
@param callback Callback to invoke when the event is caught.

Alternatively, the arguments may be provided using a map to start listening to multiple
events at once. Here, the keys of the map are eventNames and the values are callbacks.
Selectors may be specified by separating them from the event name with a space. For example:

.on({
'blur': this._blurred,
'click .some-input': this._inputClicked,
})
Starts listening to an event .