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

Method getEventInit

src/system/pointer/mouse.ts:192–209  ·  view source on GitHub ↗
(type: EventType, button?: MouseButton)

Source from the content-addressed store, hash-verified

190 }
191
192 private getEventInit(type: EventType, button?: MouseButton) {
193 const init: MouseEventInit = {
194 ...this.position.coords,
195 }
196
197 init.button = getMouseEventButton(button)
198 init.buttons = this.buttons.getButtons()
199
200 if (type === 'mousedown') {
201 init.detail = this.clickCount.getOnDown(init.button)
202 } else if (type === 'mouseup') {
203 init.detail = this.clickCount.getOnUp(init.button)
204 } else if (type === 'click' || type === 'auxclick') {
205 init.detail = this.clickCount.incOnClick(init.button)
206 }
207
208 return init
209 }
210
211 private getTarget(instance: Instance) {
212 return this.position.target ?? instance.config.document.body

Callers 3

moveMethod · 0.95
downMethod · 0.95
upMethod · 0.95

Calls 5

getMouseEventButtonFunction · 0.90
getButtonsMethod · 0.80
getOnDownMethod · 0.80
getOnUpMethod · 0.80
incOnClickMethod · 0.80

Tested by

no test coverage detected