fix(html): hydration mismatch detection ignores <script> elements
Server pages legitimately carry scripts (state serialization, analytics) that are spent by hydration time and that client views never render — they are noise to the detector, and morph dropping them is harmless. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014NgfSjHE11oFpoSnLVKLXd
This commit is contained in:
co-authored by
Claude Fable 5
parent
ce8fedee0b
commit
d755af5ca0
@@ -87,12 +87,15 @@ function firstDifference (a, b, path) {
|
||||
}
|
||||
|
||||
// child nodes that matter for comparison: everything except
|
||||
// whitespace-only text nodes
|
||||
// whitespace-only text nodes and <script> elements — server pages
|
||||
// legitimately carry scripts (state serialization, analytics) that are
|
||||
// already spent by hydration time and that client views never render
|
||||
function significant (childNodes) {
|
||||
const out = []
|
||||
for (let i = 0; i < childNodes.length; i++) {
|
||||
const node = childNodes[i]
|
||||
if (node.nodeType === 3 && !node.nodeValue.trim()) continue
|
||||
if (node.nodeType === 1 && node.nodeName === 'SCRIPT') continue
|
||||
out.push(node)
|
||||
}
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user