Return the dom and store as a js global so it doesn't get gc'd

This commit is contained in:
Vivianne 2024-10-13 18:14:04 -04:00
parent b8c368aeb4
commit b093d804c8
2 changed files with 4 additions and 4 deletions

View file

@ -1,6 +1,6 @@
window.addEventListener("load", async () => {
try {
await Scheme.load_main("scene.wasm", {
hootDom = await Scheme.load_main("scene.wasm", {
user_imports: {
document: {
getElementById(id) {

View file

@ -118,9 +118,7 @@
(button (@ (id "button")
(type "button")
(click ,(lambda (e)
(! counter (1+ (! counter)))
;; Hacky hack to ensure root-ref isn't GC'd too early...
(display root-ref))))
(! counter (1+ (! counter))))))
"Counter: "
,counter)
(button (@ (click ,(lambda (e) (! counter 0))))
@ -134,3 +132,5 @@
`(p "I want to see " ,(~ (- 20 (! counter))) " more")))))
(append-child! (document-body) (element-ref-element root-ref))
root-ref