MCPcopy
hub / github.com/vuejs/core / triggerEvent

Function triggerEvent

packages/runtime-dom/__tests__/directives/vOn.spec.ts:4–19  ·  view source on GitHub ↗
(
  target: Element,
  event: string,
  process?: (e: any) => any,
)

Source from the content-addressed store, hash-verified

2import { withKeys, withModifiers } from '@vue/runtime-dom'
3
4function triggerEvent(
5 target: Element,
6 event: string,
7 process?: (e: any) => any,
8) {
9 const e = new Event(event, {
10 bubbles: true,
11 cancelable: true,
12 })
13 if (event === 'click') {
14 ;(e as any).button = 0
15 }
16 if (process) process(e)
17 target.dispatchEvent(e)
18 return e
19}
20
21describe('runtime-dom: v-on directive', () => {
22 test('it should support "stop" and "prevent"', () => {

Callers 1

vOn.spec.tsFile · 0.70

Calls 1

processFunction · 0.50

Tested by

no test coverage detected