5

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
  • 1
    My DOM-shim has made an attempt at implementing EventTarget Commented Dec 2, 2011 at 14:26

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Event capturing is easy, emulate the entire event system, just use IE8's attachEvent and detachEvent to hook it into your own event system. Mutation events are easy, don't implement them, they are deprecated. "Key Values" sound like a difficult problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.