Update fetch for static page gen, fix DOM patching

This commit is contained in:
2026-07-13 09:51:32 -04:00
parent 9662f83319
commit ea3d2a6d03
10 changed files with 305 additions and 13 deletions

View File

@@ -129,10 +129,22 @@ func patch(parent js.Value, o, x *vdom.VNode) {
updateEvents(o, x)
if x.HTML != "" {
if x.HTML != o.HTML {
// innerHTML discards whatever DOM the old children owned, so their
// listeners go with it.
for _, c := range o.Children {
release(c)
}
dom.Set("innerHTML", x.HTML)
}
return
}
// o was raw HTML and x isn't. A Raw node keeps its markup only in the DOM
// (VNode.HTML, no Children), so patchChildren below would diff x's children
// against an empty list and *append* them after markup nothing will ever
// remove — e.g. /chart's SVG surviving a route change into /data. Clear it.
if o.HTML != "" {
dom.Set("innerHTML", "")
}
patchChildren(dom, o.Children, x.Children)
}
}