New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
D

dega

Plain JavaScript Event Delegation Library

0.1.3
latest
73

Supply Chain Security

100

Vulnerability

87

Quality

76

Maintenance

100

License

Version published
Weekly downloads
9
80%
Maintainers
1
Weekly downloads
 
Created
Issues
0

DEGA

Event delegation library on plain JavaScript.

Simple, small only 1.2kb compressed and about 620 bytes gzipped.

Tested on latest Chrome, Firefox, Safari.

Instalation

You can use Dega as global object, AMD or CommonJS module.

Install as Bower Package:

bower install dega --save

Install as NPM Module:

npm install dega --save

Loading as CommonJS module:

Dega = require('dega');

Usage

var handler = function(e) {
    e.preventDefault();

    console.log('event');
};

// Subscribe
Dega(document).on('click', '.link', handler);

// Unsubscribe
Dega(document).off('click', '.link', handler);

Dega is a self-invoking constructor, that means you shouldn't call it with new keyword.

Dega constructor accepts 2 kind of arguments:

  • HTMLElement
Dega(document)
  • String — selector which will be used in document.querySelector:
Dega('.class')
Dega('#id')
Dega('tag')

TODO

  • Remove All Events by Selector
  • Remove All Events by Type

FAQs

Package last updated on 18 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts