examples/lib/delegate.js
function off(that, listenerList, root, eventType, selector, handler) {
		var listener, nextListener, firstListener, specificList, singleEventType;

		if (!eventType) {
			for (singleEventType in listenerList) {
				if (listenerList.hasOwnProperty(singleEventType)) {
					off.call(that, that, listenerList, root, singleEventType, selector, handler);
				}
			}
			return;
		}
		specificList = listenerList[eventType];

		if (!specificList) {
			return;
		}

		// Support a separated list of event types
		if (eventType.indexOf(SEPARATOR) !== -1) {
			eventType.split(SEPARATOR).forEach(function(eventType) {
				off.call(that, that, listenerList, root, eventType, selector, handler);
			});
			return;
		}

		// Remove only parameter matches if specified
		listener = firstListener = specificList.first;
		do {
			if ((!selector || selector === listener.s) && (!handler || handler === listener.h)) {

				// listener.next will be undefined after listener is removed, so save a reference here
				nextListener = listener.next;
				specificList.remove(listener);
				listener = nextListener;
			} else {
				listener = listener.next;
			}
		} while (listener && listener !== firstListener);

		// All listeners removed
		if (!specificList.length) {
			delete listenerList[eventType];

			// Remove the main handler
			root.removeEventListener(eventType, that.handle, false);
		}
	}
function off(that, listenerList, root, eventType, selector, handler) {
		var listener, nextListener, firstListener, specificList, singleEventType;

		if (!eventType) {
			for (singleEventType in listenerList) {
				if (listenerList.hasOwnProperty(singleEventType)) {
					off.call(that, that, listenerList, root, singleEventType, selector, handler);
				}
			}
			return;
		}
		specificList = listenerList[eventType];

		if (!specificList) {
			return;
		}

		// Support a separated list of event types
		if (eventType.indexOf(SEPARATOR) !== -1) {
			eventType.split(SEPARATOR).forEach(function(eventType) {
				off.call(that, that, listenerList, root, eventType, selector, handler);
			});
			return;
		}

		// Remove only parameter matches if specified
		listener = firstListener = specificList.first;
		do {
			if ((!selector || selector === listener.s) && (!handler || handler === listener.h)) {

				// listener.next will be undefined after listener is removed, so save a reference here
				nextListener = listener.next;
				specificList.remove(listener);
				listener = nextListener;
			} else {
				listener = listener.next;
			}
		} while (listener && listener !== firstListener);

		// All listeners removed
		if (!specificList.length) {
			delete listenerList[eventType];

			// Remove the main handler
			root.removeEventListener(eventType, that.handle, false);
		}
	}
function off ( that , listenerList , root , eventType , selector , handler ) { var listener , nextListener , firstListener , specificList , singleEventType ; if ( ! eventType ) { for ( singleEventType in listenerList ) { if ( listenerList . hasOwnProperty ( singleEventType ) ) { off . call ( that , that , listenerList , root , singleEventType , selector , handler ) ; } } return ; } specificList = listenerList [ eventType ] ; if ( ! specificList ) { return ; } // Support a separated list of event types if ( eventType . indexOf ( SEPARATOR ) !== - 1 ) { eventType . split ( SEPARATOR ) . forEach ( function ( eventType ) { off . call ( that , that , listenerList , root , eventType , selector , handler ) ; } ) ; return ; } // Remove only parameter matches if specified listener = firstListener = specificList . first ; do { if ( ( ! selector || selector === listener . s ) && ( ! handler || handler === listener . h ) ) { // listener.next will be undefined after listener is removed, so save a reference here nextListener = listener . next ; specificList . remove ( listener ) ; listener = nextListener ; } else { listener = listener . next ; } } while ( listener && listener !== firstListener ) ; // All listeners removed if ( ! specificList . length ) { delete listenerList [ eventType ] ; // Remove the main handler root . removeEventListener ( eventType , that . handle , false ) ; } }
Internal function proxied by Delegate#off

@private
@param {Delegate} that
@param {Object} listenerList
@param {Node|DOMWindow} root
Internal function proxied by Delegate#off