You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
585 B
25 lines
585 B
var isStr = require('./isStr'); |
|
var defaults = require('./defaults'); |
|
var extend = require('./extend'); |
|
|
|
exports = function(el, type, opts) { |
|
if (isStr(el)) { |
|
opts = type; |
|
type = el; |
|
el = document; |
|
} |
|
opts = opts || {}; |
|
defaults(opts, defOpts); |
|
var event = document.createEvent('Event'); |
|
event.initEvent(type, opts.bubbles, opts.cancelable); |
|
delete opts.bubbles; |
|
delete opts.cancelable; |
|
extend(event, opts); |
|
el.dispatchEvent(event); |
|
}; |
|
var defOpts = { |
|
bubbles: true, |
|
cancelable: true |
|
}; |
|
|
|
module.exports = exports;
|
|
|