Skip to content

Conversation

@haozang54-source
Copy link

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

Tencent/tdesign-vue-next#6028

💡 需求背景和解决方案

  • 在 calculateNodeSize 函数中添加元素有效性检查
  • 在 calcTextareaHeight 函数中添加元素连接性验证
  • 增加 try-catch 异常处理和优雅降级
  • 修复 getComputedStyle 参数无效导致的异常

修复详情:

  1. 验证 targetElement 是否为有效的 DOM 元素
  2. 检查元素是否已连接到 DOM 树
  3. 添加异常处理确保函数不会崩溃
  4. 提供合理的默认返回值

这个修复解决了在某些边缘情况下,当 DOM 元素状态不稳定时
getComputedStyle 抛出 'parameter 1 is not of type Element' 异常的问题。

- 在 calculateNodeSize 函数中添加元素有效性检查
- 在 calcTextareaHeight 函数中添加元素连接性验证
- 增加 try-catch 异常处理和优雅降级
- 修复 getComputedStyle 参数无效导致的异常

修复详情:
1. 验证 targetElement 是否为有效的 DOM 元素
2. 检查元素是否已连接到 DOM 树
3. 添加异常处理确保函数不会崩溃
4. 提供合理的默认返回值

这个修复解决了在某些边缘情况下,当 DOM 元素状态不稳定时
getComputedStyle 抛出 'parameter 1 is not of type Element' 异常的问题。
Comment on lines +249 to +254
return {
paddingSize: 0,
borderSize: 0,
boxSizing: 'border-box',
sizingStyle: '',
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提出來一個變量

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.

2 participants