Socket
Socket
Sign inDemoInstall

@spon/domevents

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @spon/domevents

a small wrapper around dom-delegate for backbone object styled events


Version published
Maintainers
1
Install size
59.3 kB
Created

Readme

Source

Install

yarn add @spon/domevents

or

npm install @spon/domevents --save

import domEvents from '@spon/domevents'

const { addEvents, removeEvents } = domEvents(document.body)

addEvents({
	'click [data-toggle-button]': (e, elm) => {
		e.preventDefault()
		elm.classList.toggle('is-active')
	}
})

All events, by default are delegated to the node given to the initial setup. If you want to delegate to a different element, you can pass in a Dom node as the first argument , eg

addEvents(document.querySelector('.my-node'), {
	'click [data-toggle-button]': (e, elm) => {
		e.preventDefault()
		elm.classList.toggle('is-active')
	}
})

FAQs

Last updated on 20 Sep 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc