deligate

1.0.1 • Public • Published

Deligate

Simple event delegation

Currently only supports browsers with the Element.prototype.matches method

API

var deligate = require('deligate');

deligate

document.body.addEventListener('click', deligate('button.some-class', function(event){
  console.log('clicked the button');
}));
 
// ... more likely
 
var handler =  deligate('button.some-class', function(event){
  console.log('clicked the button');
});
 
document.body.addEventListener('click', handler);
 
// ... later
document.body.removeEventListener('click', handler);

Package Sidebar

Install

npm i deligate

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • allouis