MCPcopy Create free account
hub / github.com/testing-library/user-event / dispatchUIEvent

Function dispatchUIEvent

src/event/dispatchEvent.ts:8–25  ·  view source on GitHub ↗
(
  this: Instance,
  target: Element,
  type: K,
  init?: EventTypeInit<K>,
  preventDefault: boolean = false,
)

Source from the content-addressed store, hash-verified

6import {createEvent} from './createEvent'
7
8export function dispatchUIEvent<K extends EventType>(
9 this: Instance,
10 target: Element,
11 type: K,
12 init?: EventTypeInit<K>,
13 preventDefault: boolean = false,
14) {
15 if (isMouseEvent(type) || isKeyboardEvent(type)) {
16 init = {
17 ...init,
18 ...this.system.getUIEventModifiers(),
19 } as EventTypeInit<K>
20 }
21
22 const event = createEvent(type, target, init)
23
24 return dispatchEvent.call(this, target, event, preventDefault)
25}
26
27export function dispatchEvent(
28 this: Instance,

Callers

nothing calls this directly

Calls 4

isMouseEventFunction · 0.90
isKeyboardEventFunction · 0.90
createEventFunction · 0.90
getUIEventModifiersMethod · 0.80

Tested by

no test coverage detected