From b093d804c859dc4f7177d8309a39168c9966a83c Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sun, 13 Oct 2024 18:14:04 -0400 Subject: [PATCH] Return the dom and store as a js global so it doesn't get gc'd --- scene.js | 2 +- scene.scm | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scene.js b/scene.js index 7ddb838..b740295 100644 --- a/scene.js +++ b/scene.js @@ -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) { diff --git a/scene.scm b/scene.scm index 4274894..c491841 100644 --- a/scene.scm +++ b/scene.scm @@ -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