Repository navigation
fix(runtime): preserve insertAdjacentHTML node order - #19567
Single-Dancer merged 1 commit into
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
插入定位与行为验证 packages/taro-runtime/src/dom-external/node.ts, packages/taro-runtime/tests/insert-adjacent-html.spec.ts |
afterbegin 在原首子节点前插入节点,afterend 在原下一个兄弟节点前插入节点。新增测试检查节点关系、顺序及挂载后的渲染数据。 |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers: chen-jj, zakarycode
Merge Risk: 
Minimal · previous review f910c
-
The ordering fix appears ready to merge after normal checks; no actionable issue remains from the supplied evidence.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
PR 满足直接关联 issue [
#19566] 的两个编码目标。packages/taro-runtime/src/dom-external/node.ts在循环前保存firstChild和nextSibling,并通过insertBefore按解析顺序处理afterbegin和afterend;无锚点时,insertBefore(node, null)保留尾部追加行为。新增packages/taro-runtime/tests/insert-adjacent-html.spec.ts覆盖四种位置、多节点顺序、混合文本、兄弟节点、空 HTML、脱离父节点和挂载更新。
-
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
兔子轻敲节点旁,
首个锚点稳稳藏。
多个元素排成行,
文本紧随旧伙伴。
树上顺序映屏上。
Comment @coderabbitai help to get the list of available commands.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19567 +/- ##
==========================================
+ Coverage 57.26% 57.32% +0.05%
==========================================
Files 469 469
Lines 25939 25938 -1
Branches 6497 6488 -9
==========================================
+ Hits 14855 14868 +13
+ Misses 9237 9120 -117
- Partials 1847 1950 +103
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
f910cf9 to
2bc658f
Compare
这个 PR 做了什么?
修复 Taro runtime
insertAdjacentHTML的节点插入顺序:afterbegin插入多个节点时会反转顺序;afterend会把内容追加到父容器末尾,越过目标后方已有的兄弟节点。在循环前保存原始
firstChild和nextSibling,通过现有insertBefore路径按解析顺序插入。没有锚点时沿用尾部追加行为。Closes #19566
这个 PR 是什么类型?
这个 PR 涉及以下平台:
验证
setData检查最终渲染数据的节点顺序。pnpm --filter @tarojs/runtime run test:ci --maxWorkers=2:17 个测试文件通过,225 个用例通过、1 个跳过。首次默认并发运行时环境加载用例超过默认 5 秒,降低并发重跑通过,未修改测试超时或相关源码。git diff --check通过。pnpm build(包含 runtime 构建):Node.js v22.14.0 / pnpm 10.0.0,退出码 0。未修改文件中仍有类型、组件及外部依赖解析等构建告警。未进行 Vue 应用、小程序开发者工具或真机测试;没有调整解析器、特性开关或依赖。
Summary by CodeRabbit
afterbegin时,内容会插入到原有首个子节点之前;使用afterend时,会插入到目标节点的下一个兄弟节点之前。