Update fetch for static page gen, fix DOM patching
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user