diff --git a/lib/hyperscript/integration.sx b/lib/hyperscript/integration.sx index 03b6f3b7..a1a45547 100644 --- a/lib/hyperscript/integration.sx +++ b/lib/hyperscript/integration.sx @@ -115,15 +115,21 @@ (dom-set-data el "hs-script" src) (dom-set-data el "hs-active" true) (dom-set-attr el "data-hyperscript-powered" "true") - (let - ((handler (hs-handler src))) + (guard + (_e (true nil)) (let - ((el-type (dom-get-attr el "type")) - (comp-name (dom-get-attr el "component"))) - (if - (= el-type "text/hyperscript-template") - (for-each handler (hs-query-all (or comp-name ""))) - (handler el)))) + ((handler (hs-handler src))) + (let + ((el-type (dom-get-attr el "type")) + (comp-name (dom-get-attr el "component"))) + (let + ((safe-handler (fn (e) (host-call-fn handler (list e))))) + (if + (= el-type "text/hyperscript-template") + (for-each + safe-handler + (hs-query-all (or comp-name ""))) + (safe-handler el)))))) (dom-dispatch el "hyperscript:after:init" nil))))))) ;; ── Boot subtree: for dynamic content ─────────────────────────── diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index 8406f83b..f1b19360 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -73,7 +73,12 @@ ((or (= typ "ident") (= typ "keyword")) (do (adv!) - (parse-prop-chain (list (quote poss) owner val)))) + (let + ((base (list (quote poss) owner val))) + (if + (= (tp-type) "bracket-open") + (parse-poss base) + (parse-prop-chain base))))) ((= typ "attr") (do (adv!) (list (quote attr) val owner))) ((= typ "class") (let @@ -1555,7 +1560,7 @@ (fn () (let - ((tgt-raw (cond ((and (= (tp-type) "ident") (or (= (tp-val) "element") (= (tp-val) "global") (= (tp-val) "local"))) (do (adv!) (parse-expr))) (true (parse-expr))))) + ((tgt-raw (cond ((and (= (tp-type) "ident") (or (= (tp-val) "global") (= (tp-val) "local"))) (do (adv!) (parse-expr))) ((and (= (tp-type) "ident") (= (tp-val) "element")) (do (adv!) (if (and (= (tp-type) "op") (= (tp-val) "'s")) (parse-poss (list (quote ref) "element")) (parse-expr)))) (true (parse-expr))))) (let ((tgt (if (= (tp-type) "attr") (let ((attr-name (get (adv!) "value"))) (list (quote attr) attr-name tgt-raw)) tgt-raw))) (cond diff --git a/shared/static/wasm/sx/hs-integration.sx b/shared/static/wasm/sx/hs-integration.sx index 03b6f3b7..a1a45547 100644 --- a/shared/static/wasm/sx/hs-integration.sx +++ b/shared/static/wasm/sx/hs-integration.sx @@ -115,15 +115,21 @@ (dom-set-data el "hs-script" src) (dom-set-data el "hs-active" true) (dom-set-attr el "data-hyperscript-powered" "true") - (let - ((handler (hs-handler src))) + (guard + (_e (true nil)) (let - ((el-type (dom-get-attr el "type")) - (comp-name (dom-get-attr el "component"))) - (if - (= el-type "text/hyperscript-template") - (for-each handler (hs-query-all (or comp-name ""))) - (handler el)))) + ((handler (hs-handler src))) + (let + ((el-type (dom-get-attr el "type")) + (comp-name (dom-get-attr el "component"))) + (let + ((safe-handler (fn (e) (host-call-fn handler (list e))))) + (if + (= el-type "text/hyperscript-template") + (for-each + safe-handler + (hs-query-all (or comp-name ""))) + (safe-handler el)))))) (dom-dispatch el "hyperscript:after:init" nil))))))) ;; ── Boot subtree: for dynamic content ─────────────────────────── diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index 8406f83b..f1b19360 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -73,7 +73,12 @@ ((or (= typ "ident") (= typ "keyword")) (do (adv!) - (parse-prop-chain (list (quote poss) owner val)))) + (let + ((base (list (quote poss) owner val))) + (if + (= (tp-type) "bracket-open") + (parse-poss base) + (parse-prop-chain base))))) ((= typ "attr") (do (adv!) (list (quote attr) val owner))) ((= typ "class") (let @@ -1555,7 +1560,7 @@ (fn () (let - ((tgt-raw (cond ((and (= (tp-type) "ident") (or (= (tp-val) "element") (= (tp-val) "global") (= (tp-val) "local"))) (do (adv!) (parse-expr))) (true (parse-expr))))) + ((tgt-raw (cond ((and (= (tp-type) "ident") (or (= (tp-val) "global") (= (tp-val) "local"))) (do (adv!) (parse-expr))) ((and (= (tp-type) "ident") (= (tp-val) "element")) (do (adv!) (if (and (= (tp-type) "op") (= (tp-val) "'s")) (parse-poss (list (quote ref) "element")) (parse-expr)))) (true (parse-expr))))) (let ((tgt (if (= (tp-type) "attr") (let ((attr-name (get (adv!) "value"))) (list (quote attr) attr-name tgt-raw)) tgt-raw))) (cond