//go:build js && wasm
package wasmruntime
import (
"strings"
"testing"
"kjol/vdom"
)
// The reconciler is wasm-only and needs a DOM, so these do not run under a plain
// `go test ./...` (the native build of this package is an empty placeholder).
// Run them against the minimal DOM in testdata/domexec.js — from kjol/go:
//
// GOOS=js GOARCH=wasm go test -exec="node testdata/domexec.js" ./wasmruntime
// A Raw() node carries its markup in VNode.HTML and has NO children — the markup
// only exists in the DOM. So when the diff reuses that element for a node that
// has children instead (same tag, same index — e.g. a route change from a page
// with a server-rendered SVG to one without), the new children must not simply be
// appended alongside the surviving markup.
func TestPatchClearsRawHTMLWhenElementIsReused(t *testing.T) {
root := document.Call("createElement", "div")
chart := vdom.El("div", vdom.Attr("class", "grid"),
vdom.El("div", vdom.Attr("class", "cell"), vdom.Raw(``)),
)
patchChildren(root, nil, one(chart))
if got := root.Get("innerHTML").String(); !strings.Contains(got, `