Skip to content

fix(web): mts && bts events can be binded both#2121

Merged
Sherry-hue merged 1 commit intolynx-family:mainfrom
Sherry-hue:feat/mts-bts-both
Jan 20, 2026
Merged

fix(web): mts && bts events can be binded both#2121
Sherry-hue merged 1 commit intolynx-family:mainfrom
Sherry-hue:feat/mts-bts-both

Conversation

@Sherry-hue
Copy link
Copy Markdown
Collaborator

@Sherry-hue Sherry-hue commented Jan 20, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed support for simultaneously binding main-thread and bind events to the same element.
  • Tests

    • Added test coverage for concurrent main-thread and bind tap event binding and handler execution.

✏️ Tip: You can customize this high-level summary in your review settings.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 20, 2026

🦋 Changeset detected

Latest commit: ec544da

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@lynx-js/web-mainthread-apis Patch
@lynx-js/web-core-server Patch
@lynx-js/web-core Patch
@lynx-js/web-worker-runtime Patch
upgrade-rspeedy Patch
@lynx-js/web-rsbuild-server-middleware Patch
@lynx-js/web-constants Patch
@lynx-js/web-worker-rpc Patch
@lynx-js/rspeedy Patch
@lynx-js/web-core-wasm Patch
create-rspeedy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This PR refactors event handler storage in the main thread APIs to support multiple handlers per event per phase, replacing single handler references with handler arrays. It includes a new test verifying simultaneous bindtap event binding behavior across both MTS and BTS.

Changes

Cohort / File(s) Summary
Event handler refactoring
packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
Refactored event handler storage from single hname path to arrays of handlerInfo objects. Updated dispatch logic to iterate all handlers, execute worklets when present, and signal stopPropagation based on handler count. Modified __AddEvent to manage handler lists (capture/bind) as arrays and normalize/merge new handlers into appropriate lists.
Test infrastructure
.changeset/social-deer-brush.md
Added changeset file documenting patch release for @lynx-js/web-mainthread-apis with fix for simultaneous MTS and BTS event binding.
Test suite expansion
packages/web-platform/web-tests/tests/react.spec.ts, packages/web-platform/web-tests/tests/react/basic-bindtap-simultaneous/index.jsx
Added basic-bindtap-simultaneous test case and corresponding React component to verify simultaneous bindtap binding on target elements with assertions for click state, styling, and status display.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Possibly related PRs

Suggested reviewers

  • PupilTong
  • colinaaa

Poem

🐰 Multiple handlers, unified at last,
No more single paths to hold steadfast!
Bindtap and MTS dance together in sync,
Each event finds room, without a blink—
One rabbit's refactor makes handlers bloom!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main fix: enabling both MTS (main thread) and BTS (bind thread) events to be bound simultaneously, which is accurately reflected in the code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.changeset/social-deer-brush.md:
- Line 5: Update the changeset message text "fix: mts && bts events can be
binded both" to use the correct past participle by replacing "binded" with
"bound" so it reads "fix: mts && bts events can be bound both"; locate and edit
that exact string in .changeset/social-deer-brush.md.
🧹 Nitpick comments (2)
packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts (1)

358-364: Consider simplifying array initialization.

The array normalization at lines 362-364 handles cases where targetList might not be an array. However, since handler lists are now always stored as arrays (or undefined), this defensive normalization suggests potential data inconsistency concerns.

If this is for backward compatibility with existing stored data, consider adding a brief comment. Otherwise, the initialization could be simplified:

♻️ Suggested simplification
      let targetList = (isCapture
        ? runtimeInfo.eventHandlerMap[eventName]!.capture
        : runtimeInfo.eventHandlerMap[eventName]!.bind) as unknown as any[];

-      if (!Array.isArray(targetList)) {
-        targetList = targetList ? [targetList] : [];
-      }
+      // Initialize as empty array if undefined
+      targetList = targetList ?? [];
packages/web-platform/web-tests/tests/react/basic-bindtap-simultaneous/index.jsx (1)

11-15: Consider adding a verification assertion for MTS console output.

The handleMtsTap handler logs "MTS Clicked" to the console, but the test doesn't verify this output. While the data-mts-clicked attribute check confirms the handler ran, adding a console listener assertion (similar to existing tests like basic-mts-bindtap) would provide additional confidence that the MTS path executed correctly.

This is optional since the attribute check is sufficient proof of handler execution.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 0% with 92 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...b-mainthread-apis/ts/createMainThreadGlobalThis.ts 0.00% 92 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 20, 2026

Merging this PR will degrade performance by 5.46%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 61 untouched benchmarks
⏩ 3 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 45.3 ms 42 ms +7.82%
basic-performance-scroll-view-100 10.6 ms 11.2 ms -5.46%

Comparing Sherry-hue:feat/mts-bts-both (ec544da) with main (2bc3e7e)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Jan 20, 2026

Web Explorer

#7261 Bundle Size — 383.63KiB (+0.1%).

ec544da(current) vs 2bc3e7e main#7259(baseline)

Bundle metrics  Change 3 changes
                 Current
#7261
     Baseline
#7259
No change  Initial JS 154.03KiB 154.03KiB
No change  Initial CSS 35.05KiB 35.05KiB
Change  Cache Invalidation 7.36% 10.98%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 239(+0.42%) 238
No change  Duplicate Modules 16 16
Change  Duplicate Code 2.99%(-0.33%) 3%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#7261
     Baseline
#7259
Regression  JS 251.56KiB (+0.16%) 251.17KiB
No change  Other 97.02KiB 97.02KiB
No change  CSS 35.05KiB 35.05KiB

Bundle analysis reportBranch Sherry-hue:feat/mts-bts-bothProject dashboard


Generated by RelativeCIDocumentationReport issue

@Sherry-hue Sherry-hue merged commit 556fe9f into lynx-family:main Jan 20, 2026
44 of 47 checks passed
colinaaa pushed a commit that referenced this pull request Jan 25, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/react@0.116.0

### Minor Changes

- **BREAKING CHANGE**: Bump Preact from
[10.24.0](preactjs/preact@1807173)
to
[10.28.0](preactjs/preact@f7693b7),
see diffs at [hzy/preact#6](hzy/preact#6).
([#2042](#2042))

### Patch Changes

- Add safety checks for compilation macros to prevent runtime errors
when they are undefined.
([#2110](#2110))

Replaces direct usage of `__PROFILE__`, `__MAIN_THREAD__`,
`__BACKGROUND__` with `typeof` checks.

This improves robustness by checking variable existence before access,
preventing runtime errors in environments where compilation macros are
not defined.

## @lynx-js/lynx-bundle-rslib-config@0.2.0

### Minor Changes

- Use `LAYERS` exposed by DSL plugins
([#2114](#2114))

## @lynx-js/gesture-runtime@2.1.2

### Patch Changes

- Fix an issue that `NativeGesture` does not get correct types in
callback ([#2130](#2130))

## @lynx-js/rspeedy@0.13.1

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.6

## @lynx-js/react-rsbuild-plugin@0.12.6

### Patch Changes

- Support using `pluginReactLynx` in Rslib.
([#2114](#2114))

- Updated dependencies
\[[`4cd7182`](4cd7182)]:
    -   @lynx-js/template-webpack-plugin@0.10.2
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.6
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4
    -   @lynx-js/react-webpack-plugin@0.7.3
    -   @lynx-js/css-extract-webpack-plugin@0.7.0

## upgrade-rspeedy@0.13.1

### Patch Changes

- Fix the issue `rslib-runtime.js` was not published in dist folder.
([#2122](#2122))

## @lynx-js/testing-environment@0.1.10

### Patch Changes

- Fix the error "lynxTestingEnv is not defined"
([#2118](#2118))

## @lynx-js/web-constants@0.19.6

### Patch Changes

- feat: add main-thread API: \_\_QuerySelector
([#2115](#2115))

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

- feat: support main thread invoke ui method
([#2104](#2104))

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`f7133c1`](f7133c1)]:
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/web-core@0.19.6

### Patch Changes

- fix: avoid crash on CPUs that do not support SIMD
([#2133](#2133))

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`556fe9f`](556fe9f),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6
    -   @lynx-js/web-mainthread-apis@0.19.6
    -   @lynx-js/web-worker-rpc@0.19.6
    -   @lynx-js/web-worker-runtime@0.19.6

## @lynx-js/web-core-wasm@0.0.1

### Patch Changes

- Updated dependencies
\[[`f7133c1`](f7133c1)]:
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/web-mainthread-apis@0.19.6

### Patch Changes

- feat: add main-thread API: \_\_QuerySelector
([#2115](#2115))

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

- feat: support main thread invoke ui method
([#2104](#2104))

- fix: mts && bts events can be binded both
([#2121](#2121))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6

## @lynx-js/web-worker-rpc@0.19.6

### Patch Changes

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

## @lynx-js/web-worker-runtime@0.19.6

### Patch Changes

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`556fe9f`](556fe9f),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6
    -   @lynx-js/web-mainthread-apis@0.19.6
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/template-webpack-plugin@0.10.2

### Patch Changes

- Polyfill `lynx.requireModuleAsync` to allow cache same parallel
requests. ([#2108](#2108))

## create-rspeedy@0.13.1



## @lynx-js/react-alias-rsbuild-plugin@0.12.6



## @lynx-js/web-core-server@0.19.6



## @lynx-js/web-rsbuild-server-middleware@0.19.6

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Mar 24, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants