Step 18 (part 6): _hyperscript integration — _="..." attribute wiring

lib/hyperscript/integration.sx — connects compiled hyperscript to DOM:
  hs-handler(src) — compile source → callable (fn (me) ...) via eval-expr-cek
  hs-activate!(el) — read _="...", compile, execute with me=element
  hs-boot!() — scan document for [_] elements, activate all
  hs-boot-subtree!(root) — activate within subtree (for HTMX swaps)

Handler wraps compiled SX in (fn (me) (let ((it nil) (event nil)) ...))
so each element gets its own me binding and clean it/event state.
Double-activation prevented via data-hs-active marker.

12 integration tests verify full pipeline: source → compile → eval.
Handlers correctly bind me, support arithmetic, conditionals, sequences,
for loops, and repeat. 3111/3111 full build, zero regressions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-06 08:48:58 +00:00
parent 9a57bd5beb
commit f5da2bcfd5
3 changed files with 143 additions and 0 deletions

View File

@@ -1313,6 +1313,7 @@ let run_spec_tests env test_files =
load_module "parser.sx" hs_dir;
load_module "compiler.sx" hs_dir;
load_module "runtime.sx" hs_dir;
load_module "integration.sx" hs_dir;
load_module "types.sx" lib_dir;
load_module "sx-swap.sx" lib_dir;
(* Shared templates: TW styling engine *)