HS: assignableElements — set vs put distinction (+8 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s

Parser: parse-set-cmd now emits (set-el! target value) when target is
a query node (e.g. #id, .class), keeping (set! ...) for all other
targets.

Compiler: add (set-el! ...) handler that calls hs-set-element!; revert
emit-set for query targets back to hs-set-inner-html! so that
put "x" into #target keeps setting innerHTML rather than replacing
the element.

Runtime: hs-set-element! new function — parses value as HTML into a
temp div; if it contains element children, replaces the target element
via replaceChild and boots hyperscript on the new element; otherwise
falls through to hs-set-inner-html!. Removes the spurious
host-to-list wrapper that was causing len() to always return 0.

Result: all 8 assignableElements tests pass (set #id / set .class /
set closest / swap, plus put-into-still-works-as-innerHTML).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 04:46:40 +00:00
parent 0746c90729
commit 9256719fa8
7 changed files with 45 additions and 4 deletions

View File

@@ -1830,6 +1830,8 @@
(emit-set
(nth ast 1)
(hs-to-sx (nth ast 2))))
((= head (quote set-el!))
(list (quote hs-set-element!) (hs-to-sx (nth ast 1)) (hs-to-sx (nth ast 2))))
((= head (quote put!))
(let
((val (hs-to-sx (nth ast 1)))