examples/lib/delegate.js
function on(that, listenerList, root, eventType, selector, eventData, handler) {
		var matcher, matcherParam;

		if (!eventType) {
			throw new TypeError('Invalid event type: ' + eventType);
		}

		if (!selector) {
			throw new TypeError('Invalid selector: ' + selector);
		}

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

			return;
		}

		if (handler === undefined) {
			handler = eventData;
			eventData = null;

		// Normalise undefined eventData to null
		} else if (eventData === undefined) {
			eventData = null;
		}

		if (typeof handler !== 'function') {
			throw new TypeError("Handler must be a type of Function");
		}

		// Add master handler for type if not created yet
		if (!listenerList[eventType]) {
			root.addEventListener(eventType, that.handle, (eventType === 'error'));
			listenerList[eventType] = new CircularList();
		}

		// Compile a matcher for the given selector
		if (/^[a-z]+$/i.test(selector)) {
			if (!tagsCaseSensitive) {
				matcherParam = selector.toUpperCase();
			} else {
				matcherParam = selector;
			}

			matcher = matchesTag;
		} else if (/^#[a-z0-9\-_]+$/i.test(selector)) {
			matcherParam = selector.slice(1);
			matcher = matchesId;
		} else {
			matcherParam = selector;
			matcher = matches;
		}

		// Add to the list of listeners
		listenerList[eventType].append({
			s: selector,
			d: eventData,
			h: handler,
			m: matcher,
			p: matcherParam
		});
	}
function on(that, listenerList, root, eventType, selector, eventData, handler) {
		var matcher, matcherParam;

		if (!eventType) {
			throw new TypeError('Invalid event type: ' + eventType);
		}

		if (!selector) {
			throw new TypeError('Invalid selector: ' + selector);
		}

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

			return;
		}

		if (handler === undefined) {
			handler = eventData;
			eventData = null;

		// Normalise undefined eventData to null
		} else if (eventData === undefined) {
			eventData = null;
		}

		if (typeof handler !== 'function') {
			throw new TypeError("Handler must be a type of Function");
		}

		// Add master handler for type if not created yet
		if (!listenerList[eventType]) {
			root.addEventListener(eventType, that.handle, (eventType === 'error'));
			listenerList[eventType] = new CircularList();
		}

		// Compile a matcher for the given selector
		if (/^[a-z]+$/i.test(selector)) {
			if (!tagsCaseSensitive) {
				matcherParam = selector.toUpperCase();
			} else {
				matcherParam = selector;
			}

			matcher = matchesTag;
		} else if (/^#[a-z0-9\-_]+$/i.test(selector)) {
			matcherParam = selector.slice(1);
			matcher = matchesId;
		} else {
			matcherParam = selector;
			matcher = matches;
		}

		// Add to the list of listeners
		listenerList[eventType].append({
			s: selector,
			d: eventData,
			h: handler,
			m: matcher,
			p: matcherParam
		});
	}
Internal function proxied by Delegate#on

@private
@param {Delegate} that
@param {Object} listenerList
@param {Node|DOMWindow} root