Fix HS put-into and query: compiler emits hs-query-first, runtime uses real DOM
Two bugs found by automated test suite: 1. compiler.sx: query → hs-query-first (was dom-query, a deleted stub) 2. compiler.sx: emit-set with query target → dom-set-inner-html (was set!) 3. runtime.sx: hs-query-first uses real document.querySelector 4. runtime.sx: delete hs-dom-query stub (returned empty list) All 8/8 HS elements pass: toggle, bounce+wait, count, add-class, toggle-between, set-innerHTML-eval, put-into-target, repeat-3-times. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,8 @@
|
||||
((= th (quote me))
|
||||
(list (quote dom-set-inner-html) (quote me) value))
|
||||
((= th (quote it)) (list (quote set!) (quote it) value))
|
||||
((= th (quote query))
|
||||
(list (quote dom-set-inner-html) (hs-to-sx target) value))
|
||||
(true (list (quote set!) (hs-to-sx target) value)))))))
|
||||
(define
|
||||
emit-on
|
||||
@@ -483,7 +485,7 @@
|
||||
(true (list (quote host-get) target prop)))))
|
||||
((= head (quote ref)) (make-symbol (nth ast 1)))
|
||||
((= head (quote query))
|
||||
(list (quote dom-query) (nth ast 1)))
|
||||
(list (quote hs-query-first) (nth ast 1)))
|
||||
((= head (quote attr))
|
||||
(list
|
||||
(quote dom-get-attr)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -136,7 +136,9 @@
|
||||
(find-prev sibling)))))
|
||||
|
||||
;; First element matching selector within a scope.
|
||||
(define hs-query-first (fn (sel) (hs-dom-query sel)))
|
||||
(define
|
||||
hs-query-first
|
||||
(fn (sel) (host-call (host-global "document") "querySelector" sel)))
|
||||
|
||||
;; Last element matching selector.
|
||||
(define
|
||||
@@ -466,8 +468,6 @@
|
||||
d))))
|
||||
;; ── Sandbox/test runtime additions ──────────────────────────────
|
||||
;; Property access — dot notation and .length
|
||||
(define hs-dom-query (fn (selector) (list)))
|
||||
;; DOM query stub — sandbox returns empty list
|
||||
(define
|
||||
hs-method-call
|
||||
(fn
|
||||
@@ -490,13 +490,13 @@
|
||||
(if (= (first lst) item) i (idx-loop (rest lst) (+ i 1))))))
|
||||
(idx-loop obj 0)))
|
||||
(true nil))))
|
||||
;; Method dispatch — obj.method(args)
|
||||
;; DOM query stub — sandbox returns empty list
|
||||
(define hs-beep (fn (v) v))
|
||||
;; Method dispatch — obj.method(args)
|
||||
(define hs-prop-is (fn (obj key) (not (hs-falsy? (host-get obj key)))))
|
||||
|
||||
;; ── 0.9.90 features ─────────────────────────────────────────────
|
||||
;; beep! — debug logging, returns value unchanged
|
||||
(define hs-prop-is (fn (obj key) (not (hs-falsy? (host-get obj key)))))
|
||||
;; Property-based is — check obj.key truthiness
|
||||
(define
|
||||
hs-slice
|
||||
(fn
|
||||
@@ -505,7 +505,7 @@
|
||||
((s (if (nil? start) 0 start))
|
||||
(e (if (nil? end) (len col) (+ end 1))))
|
||||
(slice col s e))))
|
||||
;; Array slicing (inclusive both ends)
|
||||
;; Property-based is — check obj.key truthiness
|
||||
(define
|
||||
hs-sorted-by
|
||||
(fn
|
||||
@@ -515,7 +515,7 @@
|
||||
(map
|
||||
(fn (p) (nth p 1))
|
||||
(sort (fn (a b) (if (< (first a) (first b)) true false)) pairs)))))
|
||||
;; Collection: sorted by
|
||||
;; Array slicing (inclusive both ends)
|
||||
(define
|
||||
hs-sorted-by-desc
|
||||
(fn
|
||||
@@ -525,11 +525,11 @@
|
||||
(map
|
||||
(fn (p) (nth p 1))
|
||||
(sort (fn (a b) (if (> (first a) (first b)) true false)) pairs)))))
|
||||
;; Collection: sorted by descending
|
||||
;; Collection: sorted by
|
||||
(define hs-split-by (fn (s sep) (split s sep)))
|
||||
;; Collection: split by
|
||||
;; Collection: sorted by descending
|
||||
(define hs-joined-by (fn (col sep) (join sep col)))
|
||||
;; Collection: joined by
|
||||
;; Collection: split by
|
||||
(define
|
||||
hs-sorted-by
|
||||
(fn
|
||||
@@ -565,8 +565,7 @@
|
||||
(append acc (list (nth found 1)))
|
||||
(filter (fn (x) (not (= x found))) remaining)))))))
|
||||
(reorder sorted-dec (list) decorated)))))
|
||||
|
||||
;; Override sorted-by — use decorate-sort-undecorate (no comparator arg to sort)
|
||||
;; Collection: joined by
|
||||
(define
|
||||
hs-sorted-by-desc
|
||||
(fn (col key-fn) (reverse (hs-sorted-by col key-fn))))
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -991,7 +991,6 @@
|
||||
"hs-last",
|
||||
"hs-template",
|
||||
"hs-make-object",
|
||||
"hs-dom-query",
|
||||
"hs-method-call",
|
||||
"hs-beep",
|
||||
"hs-prop-is",
|
||||
|
||||
Reference in New Issue
Block a user