dist/jbone.js
function(el, types, handler, selector) {
        var removeListener = function(events, eventType, index, el, e) {
                var callback;

                // get callback
                if ((handler && e.originfn === handler) || !handler) {
                    callback = e.fn;
                }

                if (events[eventType][index].fn === callback) {
                    // remove handler from cache
                    events[eventType].splice(index, 1);

                    if (!events[eventType].length) {
                        el.removeEventListener(eventType, callback);
                    }
                }
            },
            events = jBone.getData(el).events,
            l,
            eventsByType;

        if (!events) {
            return;
        }

        // remove all events
        if (!types && events) {
            return keys(events).forEach(function(eventType) {
                eventsByType = events[eventType];
                l = eventsByType.length;

                while(l--) {
                    removeListener(events, eventType, l, el, eventsByType[l]);
                }
            });
        }

        types.split(" ").forEach(function(eventName) {
            var eventType = eventName.split(".")[0],
                namespace = eventName.split(".").splice(1).join("."),
                e;

            // remove named events
            if (events[eventType]) {
                eventsByType = events[eventType];
                l = eventsByType.length;

                while(l--) {
                    e = eventsByType[l];
                    if ((!namespace || (namespace && e.namespace === namespace)) &&
                        (!selector  || (selector  && e.selector === selector))) {
                        removeListener(events, eventType, l, el, e);
                    }
                }
            }
            // remove all namespaced events
            else if (namespace) {
                keys(events).forEach(function(eventType) {
                    eventsByType = events[eventType];
                    l = eventsByType.length;

                    while(l--) {
                        e = eventsByType[l];
                        if (e.namespace.split(".")[0] === namespace.split(".")[0]) {
                            removeListener(events, eventType, l, el, e);
                        }
                    }
                });
            }
        });
    }
function(el, types, handler, selector) {
        var removeListener = function(events, eventType, index, el, e) {
                var callback;

                // get callback
                if ((handler && e.originfn === handler) || !handler) {
                    callback = e.fn;
                }

                if (events[eventType][index].fn === callback) {
                    // remove handler from cache
                    events[eventType].splice(index, 1);

                    if (!events[eventType].length) {
                        el.removeEventListener(eventType, callback);
                    }
                }
            },
            events = jBone.getData(el).events,
            l,
            eventsByType;

        if (!events) {
            return;
        }

        // remove all events
        if (!types && events) {
            return keys(events).forEach(function(eventType) {
                eventsByType = events[eventType];
                l = eventsByType.length;

                while(l--) {
                    removeListener(events, eventType, l, el, eventsByType[l]);
                }
            });
        }

        types.split(" ").forEach(function(eventName) {
            var eventType = eventName.split(".")[0],
                namespace = eventName.split(".").splice(1).join("."),
                e;

            // remove named events
            if (events[eventType]) {
                eventsByType = events[eventType];
                l = eventsByType.length;

                while(l--) {
                    e = eventsByType[l];
                    if ((!namespace || (namespace && e.namespace === namespace)) &&
                        (!selector  || (selector  && e.selector === selector))) {
                        removeListener(events, eventType, l, el, e);
                    }
                }
            }
            // remove all namespaced events
            else if (namespace) {
                keys(events).forEach(function(eventType) {
                    eventsByType = events[eventType];
                    l = eventsByType.length;

                    while(l--) {
                        e = eventsByType[l];
                        if (e.namespace.split(".")[0] === namespace.split(".")[0]) {
                            removeListener(events, eventType, l, el, e);
                        }
                    }
                });
            }
        });
    }
function ( el , types , handler , selector ) { var removeListener = function ( events , eventType , index , el , e ) { var callback ; // get callback if ( ( handler && e . originfn === handler ) || ! handler ) { callback = e . fn ; } if ( events [ eventType ] [ index ] . fn === callback ) { // remove handler from cache events [ eventType ] . splice ( index , 1 ) ; if ( ! events [ eventType ] . length ) { el . removeEventListener ( eventType , callback ) ; } } } , events = jBone . getData ( el ) . events , l , eventsByType ; if ( ! events ) { return ; } // remove all events if ( ! types && events ) { return keys ( events ) . forEach ( function ( eventType ) { eventsByType = events [ eventType ] ; l = eventsByType . length ; while ( l -- ) { removeListener ( events , eventType , l , el , eventsByType [ l ] ) ; } } ) ; } types . split ( " " ) . forEach ( function ( eventName ) { var eventType = eventName . split ( "." ) [ 0 ] , namespace = eventName . split ( "." ) . splice ( 1 ) . join ( "." ) , e ; // remove named events if ( events [ eventType ] ) { eventsByType = events [ eventType ] ; l = eventsByType . length ; while ( l -- ) { e = eventsByType [ l ] ; if ( ( ! namespace || ( namespace && e . namespace === namespace ) ) && ( ! selector || ( selector && e . selector === selector ) ) ) { removeListener ( events , eventType , l , el , e ) ; } } } // remove all namespaced events else if ( namespace ) { keys ( events ) . forEach ( function ( eventType ) { eventsByType = events [ eventType ] ; l = eventsByType . length ; while ( l -- ) { e = eventsByType [ l ] ; if ( e . namespace . split ( "." ) [ 0 ] === namespace . split ( "." ) [ 0 ] ) { removeListener ( events , eventType , l , el , e ) ; } } } ) ; } } ) ; }
Remove an event handler
@param  {Node}       el        - Events will be deattached from this DOM Node
@param  {String}     types     - One or more space-separated event types and optional namespaces
@param  {Function}   handler   - A handler function previously attached for the event(s)
@param  {String}     [selector] - A selector string to filter the descendants of the selected elements
Remove an event handler