Modular javascript event library

268 views Asked by At

I want a small library that does DOM4 events. Failing that a sensible subset of DOM3 events will do.

Does it exist?

Answers that are not valid

  • Use large framework X (jQuery, mootools, prototype, etc)
  • Some library that doesn't work in IE8
  • Libraries that do not allow for both capture and bubble phases.

It only needs to work in IE8

1

There are 1 answers

1
Andy E On BEST ANSWER

I can say with reasonable confidence the answer is no. There was talk of a library called DOMe for level 3 events, but I don't think it ever got off the ground.

There are several reasons why such a library would be difficult:

  • IE 8's never even heard of event capturing (even though it was originally Microsoft's idea).
  • Mutation events are virtually impossible to shim.
  • KeyboardEvent would be a nightmare to get right because of Key Values, I'm not sure it's even feasible to attempt it. This is because keyCode can vary between input languages.

With all that in mind, small library is starting to sound a little too optimistic. To get around the first problem, you'd need to implement the entire event model by binding a handler to an original event that bubbles and pseudo-refire the event on handlers attached via your shimmed methods, starting on the document and working your way to the original event's srcElement/target and back again.

The simplest solution is probably another reason a shim doesn't exist, most people just shim the events they need, if possible, and try to avoid the need for capturing.