vue3-yuanma/packages/vue-compat/__tests__/utils.ts

12 lines
243 B
TypeScript
Raw Normal View History

2021-04-30 04:21:55 +08:00
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
}