Fix :ref callback bug in adapter-dom — Pretext island fully working
Root cause: adapter-dom.sx line 345 handled :ref by calling (dict-set! attr-val "current" el), assuming React-style ref objects. Callback-style refs (fn (el) ...) passed a function, not a dict, causing dict-set! to fail with "dict key val" error. Fix: (if (callable? attr-val) (attr-val el) (dict-set! attr-val "current" el)) Supports both callback refs and dict refs. Pretext island now fully working: - 3 controls: width slider, font size slider, algorithm toggle - Knuth-Plass + greedy line breaking via bytecode-compiled library - canvas.measureText for pixel-perfect browser font metrics - Effect-based imperative DOM rendering (createElement + appendChild) - Reactive: slider drag → re-measure → re-break → re-render Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -444,10 +444,31 @@
|
||||
((dict? v) (= (len (keys v)) 0))
|
||||
(true false))))
|
||||
;; Array slicing (inclusive both ends)
|
||||
(define hs-first (fn (lst) (first lst)))
|
||||
(define
|
||||
hs-empty-target!
|
||||
(fn
|
||||
(target)
|
||||
(cond
|
||||
((list? target) (for-each (fn (el) (hs-empty-target! el)) target))
|
||||
((nil? target) nil)
|
||||
(true
|
||||
(let
|
||||
((tag (dom-get-prop target "tagName")))
|
||||
(cond
|
||||
((or (= tag "INPUT") (= tag "TEXTAREA"))
|
||||
(let
|
||||
((input-type (dom-get-prop target "type")))
|
||||
(if
|
||||
(or (= input-type "checkbox") (= input-type "radio"))
|
||||
(dom-set-prop target "checked" false)
|
||||
(dom-set-prop target "value" ""))))
|
||||
((= tag "FORM") (dom-set-inner-html target ""))
|
||||
(true (dom-set-inner-html target ""))))))))
|
||||
;; Collection: sorted by
|
||||
(define hs-last (fn (lst) (last lst)))
|
||||
(define hs-first (fn (lst) (first lst)))
|
||||
;; Collection: sorted by descending
|
||||
(define hs-last (fn (lst) (last lst)))
|
||||
;; Collection: split by
|
||||
(define
|
||||
hs-template
|
||||
(fn
|
||||
@@ -533,7 +554,7 @@
|
||||
(set! i (+ i 1))
|
||||
(tpl-loop)))))))
|
||||
(do (tpl-loop) result))))
|
||||
;; Collection: split by
|
||||
;; Collection: joined by
|
||||
(define
|
||||
hs-make-object
|
||||
(fn
|
||||
@@ -545,7 +566,7 @@
|
||||
(fn (pair) (dict-set! d (first pair) (nth pair 1)))
|
||||
pairs)
|
||||
d))))
|
||||
;; Collection: joined by
|
||||
|
||||
(define
|
||||
hs-method-call
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user