var addEventListenerTo, removeEventListenerFrom;
if (window.attachEvent) {
addEventListenerTo = function(element, eventName, listener) {
/* Proper implementation is non-trivial:
+ 'listener' should get the fired event as 1st argument.
+ 'eventName' is the DOM event name, which doesn't start with 'on'. 'attachEvent' expects event names
to begin with 'on'. Not all DOM events can be mapped to an IE event by prefixing 'on'.
+ IE will leak event listeners. When you add a listener, hook window's unload event to detach the listener.
+ Within the listener, 'this' must be bound to the object the listener is registered on, which is
+ 'element'.
+ The biggest issue (because it's not solvable using IE events) is that event capturing can't be supported.
Oh, well.
The more you implement, the more useful the library is. Not all of the features need to be
implemented immediately; they can be added as needed. Ain't separation of concerns grand?
*/
}
removeEventListenerFrom = function(element, event, listener) {
// implementation is almost trivial.
}
} else {
addEventListenerTo = function(element, event, listener) {
// implementation is trivial
}
removeEventListenerFrom = function(element, event, listener) {
// implementation is trivial
}
}