New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

dispatch-event

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dispatch-event

Dispatch an event from a DOM element

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

dispatch-event Build Status

Dispatch an event from a DOM element

Install

$ npm install --save dispatch-event

Usage

var dispatchEvent = require('dispatch-event')
var div = document.createElement('div')

div.addEventListener('click', function onClick (event) {
  console.log('Clicked!')  
})

// Use the shorthand
dispatchEvent(div, 'click', {
  button: 2
})
//=> clicked!

// or an already constructed event object
var event = new MouseEvent('click', {
  button: 2
})
dispatchEvent(div, event)

API

dispatchEvent(element, event, [options]) -> event

Dispatches the event and returns the event.

element

Required
Type: DOMElement

A DOM element on which the event will be dispatched.

event

Required
Type: string / event

A full event object or an event name.

options

Type: object
Default: {}

Event options. Only used when event is a string. When an existing event is passed in, this will be ignored.

License

MIT © Ben Drucker

Keywords

dispatch

FAQs

Package last updated on 30 Jul 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