MCPcopy
hub / github.com/react/react / createMouseEvent

Function createMouseEvent

packages/dom-event-testing-library/domEvents.js:167–217  ·  view source on GitHub ↗
(
  type,
  {
    altKey = false,
    button = buttonType.none,
    buttons = buttonsType.none,
    ctrlKey = false,
    detail = 1,
    metaKey = false,
    movementX = 0,
    movementY = 0,
    offsetX = 0,
    offsetY = 0,
    pageX,
    pageY,
    preventDefault = emptyFunction,
    screenX,
    screenY,
    shiftKey = false,
    timeStamp,
    x = 0,
    y = 0,
  } = {},
)

Source from the content-addressed store, hash-verified

165}
166
167function createMouseEvent(
168 type,
169 {
170 altKey = false,
171 button = buttonType.none,
172 buttons = buttonsType.none,
173 ctrlKey = false,
174 detail = 1,
175 metaKey = false,
176 movementX = 0,
177 movementY = 0,
178 offsetX = 0,
179 offsetY = 0,
180 pageX,
181 pageY,
182 preventDefault = emptyFunction,
183 screenX,
184 screenY,
185 shiftKey = false,
186 timeStamp,
187 x = 0,
188 y = 0,
189 } = {},
190) {
191 const modifierState = {altKey, ctrlKey, metaKey, shiftKey};
192
193 return createEvent(type, {
194 altKey,
195 button,
196 buttons,
197 clientX: x,
198 clientY: y,
199 ctrlKey,
200 detail,
201 getModifierState(keyArg) {
202 return createGetModifierState(keyArg, modifierState);
203 },
204 metaKey,
205 movementX,
206 movementY,
207 offsetX,
208 offsetY,
209 pageX: pageX || x,
210 pageY: pageY || y,
211 preventDefault,
212 screenX: screenX === 0 ? screenX : x,
213 screenY: screenY === 0 ? screenY : y + defaultBrowserChromeSize,
214 shiftKey,
215 timeStamp,
216 });
217}
218
219function createTouchEvent(type, payload) {
220 return createEvent(type, {

Callers 11

clickFunction · 0.85
contextmenuFunction · 0.85
dragstartFunction · 0.85
virtualclickFunction · 0.85
mousedownFunction · 0.85
mouseenterFunction · 0.85
mouseleaveFunction · 0.85
mousemoveFunction · 0.85
mouseoutFunction · 0.85
mouseoverFunction · 0.85
mouseupFunction · 0.85

Calls 1

createEventFunction · 0.70

Tested by

no test coverage detected