vue2/test/helpers/trigger-event.ts

10 lines
253 B
TypeScript
Raw Normal View History

2016-05-27 01:54:37 +08:00
window.triggerEvent = function triggerEvent (target, event, process) {
const e = document.createEvent('HTMLEvents')
2016-05-27 01:54:37 +08:00
e.initEvent(event, true, true)
if (event === 'click') {
e.button = 0
}
2016-05-27 01:54:37 +08:00
if (process) process(e)
target.dispatchEvent(e)
}