Skip to content

micro-js/create-event

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

create-event

Build status Git tag NPM version Code style

Create a DOM event

Installation

$ npm install @f/create-event

Usage

You can use this library to trigger synthetic events on elements for testing or other purposes. E.g.s

var createEvent = require('@f/create-event')

function triggerEvent (node, type, opts) {
  var e = createEvent(type, opts)
  node.dispatchEvent(e)
}

API

createEvent(type, opts)

  • type - The name of the event. E.g. mouseover or click.
  • opts - Optional. Object containing special properties you want to set on the event. These will be event-specific.

Returns: A DOM event object created by the appropriate event constructor.

License

MIT