fix: 修复 Table 使用 treeExpandKeys 时 data 含不可序列化字段导致页面崩溃的问题#2215
Merged
Conversation
- 新增 safeDeepClone 工具函数替代 JSON.parse(JSON.stringify()) 进行深拷贝 - 通过 WeakMap 处理循环引用,跳过 React 元素和 DOM 节点 - 保留断开 data 引用的能力,确保直接修改 data 后 Table 仍能响应式更新
saint3347
force-pushed
the
fix/table-tree-expand-circular-json
branch
from
May 20, 2026 11:48
8fde2fc to
13e731a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
Table 组件使用
treeExpandKeys展开树形行时,若data中包含 DOM 节点引用、React Ref 等不可 JSON 序列化的字段,JSON.parse(JSON.stringify(data))会因循环引用直接报错导致页面崩溃。修复方案
新增
safeDeepClone工具函数替代JSON.stringify深拷贝:$$typeof)和 DOM 节点,保持原引用测试