MCPcopy
hub / github.com/Shopify/draggable / triggerEvent

Function triggerEvent

test/helpers/event.ts:3–24  ·  view source on GitHub ↗
(
  element: HTMLElement,
  type: string,
  data: {[key: string]: any} = {},
)

Source from the content-addressed store, hash-verified

1import {withElementFromPoint} from './environment';
2
3export function triggerEvent(
4 element: HTMLElement,
5 type: string,
6 data: {[key: string]: any} = {},
7) {
8 const event = document.createEvent('Event');
9 event.initEvent(type, true, true);
10
11 for (const key in data) {
12 if (Object.prototype.hasOwnProperty.call(data, key)) {
13 Object.defineProperty(event, key, {
14 value: data[key],
15 });
16 }
17 }
18
19 withElementFromPoint(element, () => {
20 element.dispatchEvent(event);
21 });
22
23 return event;
24}

Callers 13

clickMouseFunction · 0.90
moveMouseFunction · 0.90
releaseMouseFunction · 0.90
touchStartFunction · 0.90
touchMoveFunction · 0.90
touchReleaseFunction · 0.90
dragStartFunction · 0.90
dragOverFunction · 0.90
dragDropFunction · 0.90
dragStopFunction · 0.90

Calls 1

withElementFromPointFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…