HS: implement morph command — tokenizer keyword, parser, compiler, runtime HTML-fragment parser

Adds the missing `morph <target> to <html>` command. Runtime includes a small
HTML fragment parser that applies the outer element's attributes to the target,
rebuilds children, and re-activates hyperscript on the new subtree. Other
hyperscript fixes (^ attr ref, dom-ref keyword, pick keyword, between in am/is,
prop-is removal) from parallel work are bundled along.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-22 11:49:36 +00:00
parent ef5faa6b54
commit 5b0c8569a8
4 changed files with 735 additions and 68 deletions

View File

@@ -117,6 +117,7 @@
"first"
"last"
"random"
"pick"
"empty"
"clear"
"swap"
@@ -173,11 +174,16 @@
"default"
"halt"
"precedes"
"precede"
"follow"
"follows"
"ignoring"
"case"
"changes"
"focus"
"blur"))
"blur"
"dom"
"morph"))
(define hs-keyword? (fn (word) (some (fn (k) (= k word)) hs-keywords)))
@@ -472,6 +478,14 @@
(hs-advance! 1)
(hs-emit! "attr" (read-ident pos) start)
(scan!))
(and
(= ch "^")
(< (+ pos 1) src-len)
(hs-ident-char? (hs-peek 1)))
(do
(hs-advance! 1)
(hs-emit! "hat" (read-ident pos) start)
(scan!))
(and
(= ch "~")
(< (+ pos 1) src-len)