How to use registerSimpleEvents method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

SimpleEventPlugin.js

Source: SimpleEventPlugin.js Github

copy
1import {
2  registerSimpleEvents,
3  topLevelEventsToReactNames,
4} from "./DOMEventProperties"
5import { SyntheticMouseEvent } from "./SyntheicEvent"
6import { IS_CAPTURE_PHASE } from "./EventSystemFlags"
7import { accumulateSinglePhaseListeners } from "./DOMPluginEvnentSystem"
8
9function extractEvents(
10  dispatchQueue,
11  domEventName,
12  targetInst,
13  nativeEvent,
14  nativeEventTarget,
15  eventSystemFlags,
16  targetContainer
17) {
18  let reactName = topLevelEventsToReactNames.get(domEventName) // click=> onClick
19  let SyntheticEventCtor
20  let reactEventType = domEventName
21  // 不同的事件,合成事件对象是不一样的,不同的事件对应不同的合成事件构造函数
22  switch (domEventName) {
23    case "click":
24      SyntheticEventCtor = SyntheticMouseEvent
25      break
26    default:
27      break
28  }
29  let inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0
30  const listeners = accumulateSinglePhaseListeners(
31    targetInst,
32    reactName,
33    nativeEvent.type,
34    inCapturePhase
35  )
36  if (listeners.length > 0) {
37    // 如果有监听,就创建一个新的合成事件对象
38    const event = new SyntheticEventCtor(
39      reactName,
40      reactEventType,
41      targetInst,
42      nativeEvent,
43      nativeEventTarget
44    )
45    dispatchQueue.push({
46      event,
47      listeners,
48    })
49  }
50}
51
52export { registerSimpleEvents as registerEvents, extractEvents }
53
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Internal on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)