domeventlogger

Util for discovering events being emitted by browser apis and dom nodes

npm install domeventlogger
6 downloads in the last week
12 downloads in the last month

domEventLogger

What is this?

A tiny browser module for discovering what events are actually being fired by an object in the browser. Especially useful for discovering available 'hooks' for new-ish browser APIs like MediaStreams or PeerConnections.

It does this without overwriting an existing handlers you may have already registered.

Suitable for use with browserify/CommonJS on the client.

If you're not using browserify or you want AMD support use domeventlogger.bundle.js.

Installing

npm install domeventlogger

How to use it

See demo.html for working demo.

var domEventLogger = require('domeventlogger');


// grab some image or any browser API that lets you
// listen for 'on...' events:
img = document.getElementById('myImage');

// specify that you want to log events
domEventLogger(img);

// do something that will cause an event
// for example a "onload" event by specifying
// an image source attribute.
img.src = "http://myawesomeimage.com";

// look in your console and you'll see the load event logged
// now you can mouse over the image and see mouseover, etc.
// this is great for discovering what hooks you have available to you.

Example

screen shot

Why?

New browser APIs don't always have perfect up-to-date docs. And sometimes you're not exactly sure the order in which things are firing. This can make it easier to debug.

Caveats

Don't leave this in your code in production, as it registers an event listen on every possible event hook for the element you pass it (which may not be particularly awesome for performance);

License

MIT

Created By

If you like this, follow @HenrikJoreteg on twitter.

npm loves you