Skip to content

fix(engine-dom): t8s1 DOMParser 快照 Text/Comment adopt 物化——insertBefore ref 无 handle 静默丢元素 - #132

Merged
leizongmin merged 2 commits into
mainfrom
t8s1-adopt-snapshot-text
Oct 10, 2026
Merged

leizongmin merged 2 commits into
mainfrom
t8s1-adopt-snapshot-text

Conversation

@leizongmin

@leizongmin leizongmin commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

变化

真站 bilibili 视频页 npd.314 播放器 danmaku widget install 链崩簇(Cannot read properties of null ×4 消费点:resize/hideDm/renderParts/classList 全读 template.info/online)根因修复。

根因链(真站证据 + 微探针矩阵三角化定谳)

  1. 模板引擎 T.d(npd.314 bundle 模块 86806)装载 UI 用 while(body.lastChild) frag.insertBefore(document.adoptNode(body.lastChild), frag.firstChild||null) 倒序排空 DOMParser 快照 body;renderFragment HTML 带尾随空白 → body 末子是文本节点。
  2. t8q(PR fix(engine-dom): adoptNode 物化 DOMParser 快照产物,修 bilibili nano 播放器容器空壳挂载 #129)的 adoptNode 物化只覆盖 nodeType===1:快照顶层裸 Text 走 R192 既有分支 identity 返回,无 host handle。
  3. 该文本插入 handle fragment 成功(ref=null 路径),但其作 ref 时 host 桥按 ref handle 定位失败 → 第二轮 adopt 的 div 元素静默丢失(无异常、无插入)。
  4. fragment append 后 .bpx-video-info 注册表查询全 miss → 四消费点 null 崩。

微探针矩阵(执行体 about:blank CDP,修复前二进制):坏格精确为 {DOMParser adopt 快照文本作 ref} × {ref 非 null 的 fragment.insertBefore}——ref=本地文本(M2)、ref=null(M4)、普通文档节点同组合(R4)全部正常;single-op adoptNode/lastChild/removeChild(Q1-Q4)全对。

修复(最小面,3 文件)

  • part03.js:_zwMText/_zwMComment 盖 __zwIsMEl 家族印章(与 _zwMEl 同款 non-enumerable;全库唯一运行时消费者是 adoptNode 落地分支守卫)。
  • part06.js:adoptNode 守卫与物化返回判定 nodeType===1 → 1|3|8;_zwParseEl instanceof || __zwIsMEl 双识别保持。
  • spec 依据:https://dom.spec.whatwg.org/#concept-node-adopt (adopt 完整搬入本文档)。

验证

层 结果
钉测(新增 ×2,part18.rs) 主钉测 T.d 倒序排空真站同构 + v.W 消费面查询/style;变体钉测 Comment ref 与 data 保真 + 文本数据保真/原父摘除/快照与 handle/物化产物二次 adopt identity 零回归
红→绿 /tmp 备份 + 手动反向 shim → 旧代码读数 fragTypes:3|fragInfo:miss|barInfo:null(与真站崩读数同构)→ cp 恢复 md5 校验 → 复跑绿
回归 zero-engine lib 全量 2967 passed(含 t8q/t8r 族);make test pipefail 复跑 MAKE_EXIT=0
clippy v8 全 workspace --all-targets -D warnings 零告警;quickjs 腿(engine)零告警
fmt cargo fmt --all -- --check 干净
执行体 make browser-build 后 grep -a -c _eMElTagT zero-renderer=1(产物本体核验)
真站 docker=true 完整初始化态两轮探针 errCount=0(修复前同条件 9-10 条同簇 error),npd.314 chunk 确认加载

双审查状态

  • 首轮 A(测试有效性):APPROVE_WITH_NITS,零阻断。
  • 首轮 B(缺陷):APPROVE_WITH_NITS,零阻断——含副作用面全库枚举(印章消费点唯一、盖章面拓宽的 identity 偏差已缓解判定、CDATA/doctype/fragment 排除门核验)。
  • 非作者复核(153b12935):APPROVE_WITH_NITS——6 nit 中 5 条闭合确认、补丁无新问题(Comment 作 ref 场景保真核验);残留 A③(XML 域入已知边界)纯正文项,本轮补充如下。①前导/尾随空白表述统一(A④/B②);②_zwMText 印章注释如实记录同文档 adopt identity 偏差面(B①);③变体钉测补 Comment data 逐字断言(A①);④补物化产物二次 adopt identity 直接断言(A②)。返修后 t8s1 钉测 2 passed + engine lib 2967 passed + fmt 干净。非作者复核进行中,完成后更新本节。

截图

无适用画面:本修复修复的是 console 层脚本崩溃簇(widget install 链 null TypeError),优化前后无对应可见画面差异——修复前崩簇由 console error 计数证明(9-10 条 → 0),已在上表与运行目录 .acceptance/site-optimizer/bilibili-20261002-r1/out-t8s1-verify{,2}/verify.json 留档。danmaku widget 本身未登录态不可见,无视觉验收面。

已知边界(不属本 PR)

  • text/xml mimeType 的 DOMParser shim 层统一按 HTML 解析,快照 Text/Comment 同走 1|3|8 物化(首轮 A③ 指认的同形面经首轮 B 核验为同域覆盖,此处如实记录口径;shim XML 根元素大小写/命名空间差异为既有已知限制,不属本 PR)
  • DOMParser 解析域丢弃 body 前导空白文本([1,3] vs Chrome [3,1,3])——独立差异已入池 OBS-t8s1-1;T.d/tr.t 链不依赖前导空白存活。
  • __zwIsMEl 盖章面含 new Text()/cloneNode 等全部 M 家族产物:其同文档 adopt 由 R192 identity 变为物化副本(spec 要求返回自身)——审查 B 核实当前 shim 无内部 adoptNode 调用方、无测试/站点消费面受害;如需 identity 保真再拆独立印章(注释已记录,part03.js)。
  • detached doc 自身 adoptNode(own 版,part06.js:3620)未扩 3/8——t8q 元素既有不对称的对称延伸,nit 级。
  • 真站终态读数 raw CDP evaluate 挂起(P-B6 既有基建缺口,error 计数走 console 通道不受影响)。

🤖 Generated with Claude Code


Note

Medium Risk
Changes adoptNode materialization for parser snapshot text/comment nodes; documented tradeoff that same-document adopt of some M-family nodes may no longer return identity (R192).

Overview
Fixes bilibili player crashes where adopting a DOMParser snapshot body in reverse order left trailing text nodes without host handles, so a later insertBefore with that text as ref silently dropped the real element and broke .bpx-video-info lookups.

Shim: _zwMText / _zwMComment now stamp __zwIsMEl, and document.adoptNode materialization applies to elements, text, and comments (not only nodeType === 1), still using _wcRebuildAsHandle and parent removal per concept-node-adopt.

Tests: Two new t8s1 bridge tests mirror the T.d drain loop plus comment-ref, data fidelity, and adopt identity regressions; t8q comments note top-level text/comment adopt is in scope.

Reviewed by Cursor Bugbot for commit 153b129. Bugbot is set up for automated code reviews on this repo. Configure here.

…e ref 无 handle 静默丢元素

真站 bilibili 播放器模板引擎 T.d(npd.314 bundle 模块 86806)用
`while(body.lastChild) frag.insertBefore(adoptNode(body.lastChild), frag.firstChild||null)`
倒序排空 DOMParser 快照 body:renderFragment HTML 带尾随空白 → 末子是文本。
t8q(PR #129)adoptNode 物化只覆盖 nodeType 1——快照文本 identity 返回无
host handle;其插入 fragment 成功但作 ref 时 host 桥按 ref handle 定位失败
→ 第二轮的元素静默丢失 → `.bpx-video-info` 注册表查询全 miss → npd.314
四处 `template.info/online` null 崩(resize/hideDm/renderParts/classList)。

修复:_zwMText/_zwMComment 盖 __zwIsMEl 家族印章(与 _zwMEl 同款
non-enumerable,唯一消费者是 adoptNode 落地分支守卫);守卫与物化返回
判定扩至 nodeType 1|3|8。spec concept-node-adopt「完整搬入本文档」。

验证:
- 钉测 ×2(js_dom_bridge_tests/part18.rs):T.d 倒序排空真站同构 + Comment
  ref/数据保真/原父摘除/identity 零回归;红态验证复现崩读数
  (fragTypes:3|barInfo:null)后恢复修复复跑绿
- zero-engine lib 2967 passed;make test MAKE_EXIT=0
- clippy v8 全 workspace + quickjs 腿 -D warnings 零告警;fmt 干净
- 真站验证:docker=true 完整态两轮 errCount=0(修复前同态 9-10 条同簇),
  npd.314 chunk 确认加载

Co-Authored-By: Claude Code <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 6376619d-a9cd-4469-b06a-61a67ce90a97)

①前导/尾随空白表述统一(首轮 A nit4 / B nit2);②_zwMText 印章注释
如实记录盖章面拓宽的同文档 adopt identity 偏差面(B nit1);③变体钉测
补 Comment data 逐字断言(A nit1);④补物化产物二次 adopt identity
直接断言(A nit2)。返修后 t8s1 钉测 2 passed + engine lib 2967 passed
+ fmt 干净。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 152b0ab4-0cee-4364-9dee-6e033fc45b9d)

@leizongmin
leizongmin merged commit 48f3a08 into main Oct 10, 2026
2 checks passed
@leizongmin
leizongmin deleted the t8s1-adopt-snapshot-text branch October 18, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant