@lynx-js/web-mainthread-apis-canary 0.18.5-canary-20251203-06ba61c9 → 0.18.5-canary-20251204-736b8322

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # @lynx-js/web-mainthread-apis
2
2
 
3
- ## 0.18.5-canary-20251203023322-06ba61c9375eab7c4e5ceaa1bd653e24d2dfca13
3
+ ## 0.18.5-canary-20251204053135-736b83223ab042c058e0fbc5040c72316e716f3f
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - fix: capture and bind event listener should be trigger correctly ([#1972](https://github.com/lynx-family/lynx-stack/pull/1972))
8
+
7
9
  - fix: the l-p-comp-uid of page should be '1' ([#1970](https://github.com/lynx-family/lynx-stack/pull/1970))
8
10
 
9
11
  - Updated dependencies []:
10
- - @lynx-js/web-constants@0.18.5-canary-20251203023322-06ba61c9375eab7c4e5ceaa1bd653e24d2dfca13
12
+ - @lynx-js/web-constants@0.18.5-canary-20251204053135-736b83223ab042c058e0fbc5040c72316e716f3f
11
13
 
12
14
  ## 0.18.4
13
15
 
@@ -27,12 +27,22 @@ export function createMainThreadGlobalThis(config) {
27
27
  ?.deref();
28
28
  let uniqueIdInc = lynxUniqueIdToElement.length || 1;
29
29
  const exposureChangedElements = new Set();
30
- const commonHandler = (event) => {
30
+ const commonHandler = (event, capture) => {
31
31
  if (!event.currentTarget) {
32
32
  return;
33
33
  }
34
+ // The `capture false` event should not be triggered during the capture-phase
35
+ // The `capture true` event should not be triggered during the bubbling phase
36
+ if ((event.eventPhase === Event.CAPTURING_PHASE && capture === false)
37
+ || (event.eventPhase === Event.BUBBLING_PHASE && capture === true)) {
38
+ return;
39
+ }
34
40
  const currentTarget = event.currentTarget;
35
- const isCapture = event.eventPhase === Event.CAPTURING_PHASE;
41
+ // When the event is triggered by the target element, `event.eventPhase` is always `target`, and the listener type is determined by the passed-in `capture`.
42
+ // When the event is triggered by a non-target element, the listener type is determined by `event.eventPhase` (1, 3).
43
+ const isCapture = event.eventPhase === Event.AT_TARGET
44
+ ? capture
45
+ : event.eventPhase === event.CAPTURING_PHASE;
36
46
  const lynxEventName = W3cEventNameToLynx[event.type] ?? event.type;
37
47
  const runtimeInfo = elementToRuntimeInfoMap.get(currentTarget);
38
48
  if (runtimeInfo) {
@@ -70,11 +80,23 @@ export function createMainThreadGlobalThis(config) {
70
80
  }
71
81
  return false;
72
82
  };
73
- const commonCatchHandler = (event) => {
74
- const handlerTriggered = commonHandler(event);
83
+ const captureHandler = (e) => {
84
+ commonHandler(e, true);
85
+ };
86
+ const defaultHandler = (e) => {
87
+ commonHandler(e, false);
88
+ };
89
+ const commonCatchHandler = (event, isCapture) => {
90
+ const handlerTriggered = commonHandler(event, isCapture);
75
91
  if (handlerTriggered)
76
92
  event.stopPropagation();
77
93
  };
94
+ const catchCaptureHandler = (e) => {
95
+ commonCatchHandler(e, true);
96
+ };
97
+ const defaultCatchHandler = (e) => {
98
+ commonCatchHandler(e, false);
99
+ };
78
100
  const __AddEvent = (element, eventType, eventName, newEventHandler) => {
79
101
  eventName = eventName.toLowerCase();
80
102
  const isCatch = eventType === 'catchEvent' || eventType === 'capture-catch';
@@ -88,8 +110,8 @@ export function createMainThreadGlobalThis(config) {
88
110
  ? runtimeInfo.eventHandlerMap[eventName]?.capture
89
111
  : runtimeInfo.eventHandlerMap[eventName]?.bind;
90
112
  const currentRegisteredHandler = isCatch
91
- ? commonCatchHandler
92
- : commonHandler;
113
+ ? (isCapture ? catchCaptureHandler : defaultCatchHandler)
114
+ : (isCapture ? captureHandler : defaultHandler);
93
115
  if (currentHandler) {
94
116
  if (!newEventHandler) {
95
117
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-mainthread-apis-canary",
3
- "version": "0.18.5-canary-20251203-06ba61c9",
3
+ "version": "0.18.5-canary-20251204-736b8322",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -26,7 +26,7 @@
26
26
  "**/*.css"
27
27
  ],
28
28
  "dependencies": {
29
- "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.18.5-canary-20251203-06ba61c9",
29
+ "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.18.5-canary-20251204-736b8322",
30
30
  "hyphenate-style-name": "^1.1.0",
31
31
  "wasm-feature-detect": "^1.8.0"
32
32
  },