angular 水分检测:检测常见的不匹配模式并生成更好的错误信息

xu3bshqb  于 5个月前  发布在  Angular
关注(0)|答案(3)|浏览(53)

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

During hydration, Angular relies on the application structure to be the same between the server and the client. There are a few cases where if you have a component template that does not have valid HTML structure, this could result in a DOM mismatch error during hydration, see https://angular.dev/guide/hydration#valid-html-structure.
Here is an example that we've came across on ADEV: #56390 .

Proposed solution

The proposal is to auto-detect those situations when hydration mismatch happens and output additional information into the console, to make it easier to find the origin of the problem and resolve it.

dzjeubhm

dzjeubhm1#

在过去的报告中提到的其他例子:

$x_{1}e^{0}f_{1}x$

$x_{1}e^{1}f_{1}x$

zzwlnbp8

zzwlnbp82#

#56712合并到这里时,我想指出在生产环境中检测这些不匹配也很重要,因为第三方脚本可能会干扰(代理、浏览器扩展等)。
由于开发者通常无法控制这些(例如用户浏览器扩展),当生产中的不匹配发生时,hydration应该恢复。

ddhy6vgd

ddhy6vgd3#

错误信息非常模糊,就像 #57063 一样。我花了超过10个小时的时间调试才得以重现问题,只是知道是因为 p 不能有嵌套的 dev。我完全不明白问题出在哪里,我唯一的想法是这一定是内部问题。

相关问题