fix: 插槽组件局部更新使得事件id增长,极端情况下可能导致页面卡死 #5033
Open
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.
插槽组件局部更新会导致事件id变化,如果插槽内有大量事件(如:插槽内是列表每条都加点击事件),每次更新都会事件id都会大量增长。
事件id变化又可能触发局部组件渲染,无限循环导致页面卡死(似乎复现条件较为苛刻,这个demo我调了好久才成功复现,且仅在钉钉小程序中有效)
https://github.com/acyza/uni-app/tree/pr_2_demo
此demo仅在钉钉小程序中复现,在开发者工具中可以看到插槽中的事件id在无限刷新(注:demo页较为简单,可能并未导致页面完全卡死,复杂点的页面是可能会卡死的)。
此pr将插槽内的id生成,从使用插槽所在组件实例生成改为使用插槽组件id+插槽组件生成事件id,确保id唯一且部分组件单独重新渲染也不会导致id无限增长