Repository navigation
fix(runtime): 修复逻辑索引未命中时事件目标信息丢失的问题 - #19528
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Walkthrough调整 Changes事件目标处理
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to
|
Preserve platform target data when the logical event index is unavailable, while retaining indexed datasets, Alipay merge order and lazy caches. Cover the behavior across WX, ZFB and TT template runtimes. Upstream: NervJS/taro#19528 Retire 05-event-target-data after upgrading the pinned @tarojs/runtime to a release containing the upstream fix; retain the regression tests.
a45e835 to
19df00a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19528 +/- ##
==========================================
+ Coverage 55.32% 55.35% +0.02%
==========================================
Files 467 467
Lines 25650 25650
Branches 6428 6421 -7
==========================================
+ Hits 14192 14199 +7
- Misses 9463 9484 +21
+ Partials 1995 1967 -28
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
这个 PR 做了什么?
修复
TaroEvent.target/currentTarget在逻辑节点索引未命中时的数据丢失和目标混淆。问题与复现
事件派发时接收节点可以正常命中索引,但处理器在首次读取事件目标前移除节点,会清除对应索引。此时原有
currentTargetgetter 因为element === null直接返回this.target,把接收事件的父节点错误替换成触发事件的子节点;targetgetter 也会用空对象替换平台仍然提供的 dataset。下面的运行时复现使用普通的单参数
eventHandler(event):修改
dataset/targetDataset的合并优先级。目标 dataset 继续使用已有的浅复制/合并流程,成本随来源字段数变化;未命中时现在复制实际平台数据,而不是空对象。索引查询次数保持不变。兜底只能保留平台事件已经携带的信息。
测试
新增 14 项运行时回归,覆盖处理器内移除节点、空/未解析 ID 与 sid、原始对象及逻辑节点身份、数据优先级、支付宝混合命中情况、缺省 dataset 和缓存查询次数。13 项在修复前失败,修复后全部通过。
本地验证:
pnpm --filter @tarojs/shared buildpnpm --filter @tarojs/runtime buildpnpm --filter @tarojs/runtime test:ci:12 个测试文件通过,148 项通过、1 项既有跳过。pnpm --filter @tarojs/runtime exec tsc --noEmitpnpm exec eslint packages/taro-runtime/src/dom/event.ts packages/taro-runtime/tests/event-target.spec.ts验证环境:macOS arm64、Node.js 26.5.0、pnpm 10.0.0。以上为运行时及构建验证;设备行为尚待验证。
这个 PR 是什么类型?
这个 PR 涉及以下平台:
TaroEvent的共享事件路径)Summary by CodeRabbit