vue3-yuanma/packages/vue-compat/__tests__/utils.ts
2021-04-29 16:58:14 -04:00

12 lines
243 B
TypeScript

export function triggerEvent(
target: Element,
event: string,
process?: (e: any) => any
) {
const e = document.createEvent('HTMLEvents')
e.initEvent(event, true, true)
if (process) process(e)
target.dispatchEvent(e)
return e
}