Fix create-text-node in DOM adapter: host handle Dicts are DOM nodes

The DOM adapter treated all Dict values as empty (create-fragment).
But DOM nodes (text nodes, elements) from create-text-node/host-call
are wrapped as Dict { __host_handle: N } by js_of_ocaml. Now checks
for __host_handle and passes them through as DOM nodes.

Fixes stopwatch button text ("Start") and timer display ("0.0s")
which were missing because create-text-node results were discarded.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 14:10:28 +00:00
parent eacde62806
commit 1e42eb62a2
2 changed files with 8 additions and 4 deletions

View File

@@ -75,8 +75,10 @@
(scope-emit! "element-attrs" (spread-attrs expr)))
expr)
;; Dict → empty
"dict" (create-fragment)
;; Dict → check for host DOM node, else empty fragment
"dict" (if (has-key? expr "__host_handle")
expr ;; Host DOM node (text node, element, etc.) — pass through
(create-fragment))
;; List → dispatch
"list"

View File

@@ -75,8 +75,10 @@
(scope-emit! "element-attrs" (spread-attrs expr)))
expr)
;; Dict → empty
"dict" (create-fragment)
;; Dict → check for host DOM node, else empty fragment
"dict" (if (has-key? expr "__host_handle")
expr ;; Host DOM node (text node, element, etc.) — pass through
(create-fragment))
;; List → dispatch
"list"