Implements event delegation.
var delegate = require('delegation');
delegate(document, 'click', 'li', function(e) {
console.log(this.nodeName); // "LI"
});
The module returns a function with four arguments:
parent
: the parent on which to listen for the eventevent
: the event to listen toselector
: the selector for the elements to delegate tohandler
: the event handler
npm install delegation
MIT License.