节点正常化 () 删除 Flagment 文本锁定并导致后续更新失败
作者: eric-gitta-moore创建于 2026年9月9日更新于 2026年9月10日
标签has workaround🔩 p2-edge-case
Steps to reproduce
- Open the reproduction link (Vue 3.5.42, DEV mode, SSR off).
- Click "1. Normalize body" to execute document.body.normalize() inside the preview frame.
- Click "2. Toggle branch".
- Observe the nextSibling error: First/Second remain visible instead of Replacement branch. Verified control: without calling normalize(), Toggle branch switches to Replacement branch and back successfully.
What is expected?
Node.normalize() removes empty text nodes and merges adjacent text nodes. Vue Fragment boundaries use empty text nodes, so normalizing an ancestor may remove these boundaries while the VNodes retain references to the original nodes. Would it be possible to preserve compatibility between Node.normalize() and Fragment anchors?
What is actually happening?
The issue is reproducible. After clicking Normalize body and then Toggle branch, the update fails: First/Second remain visible instead of Replacement branch. Without normalization, switching in both directions works. Error stack:
TypeError: Cannot read properties of null (reading 'nextSibling')
at nextSibling (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:7607:30)
at removeFragment (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:6128:11)
at remove (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:6107:9)
at unmount (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:6091:18)
at patch (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:5503:4)
at patchBlockChildren (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:5696:4)
at patchElement (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:5662:4)
at processElement (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:5584:5)
at patch (http://127.0.0.1:5179/node_modules/.vite/deps/vue_dist_vue__esm-bundler__js.js?v=895c4d76:5525:32)
at ReactiveEffect.componentUpdateFn [as fn]
…
内容来源: vuejs/core