HS: hyperscript:before:init / :after:init events (+2 tests)
integration.sx hs-activate! now wraps the activation block in a cancelable hyperscript:before:init event (dispatched on the el via dom-dispatch which returns the dispatchEvent boolean — true unless preventDefault was called). On success it dispatches hyperscript:after:init at the end. Both events bubble so listeners on a containing wa work-area receive them. Generator gets two hand-rolled deftests that exercise the new dispatch via hs-boot-subtree!: one captures both events into a list, the other preventDefaults before:init and asserts data-hyperscript-powered is absent. hs-upstream-core/bootstrap: 20/26 → 22/26. Smoke 0-195: 170 → 172. Remaining 4 cluster-29 tests need stricter parser error-rejection (hs-upstream-core/parser, parse-error event); larger than a single cluster budget — leave as untranslated for now. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1396,7 +1396,17 @@
|
||||
(hs-activate! _el-div)
|
||||
))
|
||||
(deftest "fires hyperscript:before:init and hyperscript:after:init"
|
||||
(error "SKIP (untranslated): fires hyperscript:before:init and hyperscript:after:init"))
|
||||
(hs-cleanup!)
|
||||
(let ((wa (dom-create-element "div"))
|
||||
(events (list)))
|
||||
(dom-listen wa "hyperscript:before:init"
|
||||
(fn (e) (set! events (append events (list "before:init")))))
|
||||
(dom-listen wa "hyperscript:after:init"
|
||||
(fn (e) (set! events (append events (list "after:init")))))
|
||||
(dom-set-inner-html wa "<div _=\"on click add .foo\"></div>")
|
||||
(hs-boot-subtree! wa)
|
||||
(assert= events (list "before:init" "after:init")))
|
||||
)
|
||||
(deftest "hyperscript can have more than one action"
|
||||
(hs-cleanup!)
|
||||
(let ((_el-bar (dom-create-element "div")) (_el-div (dom-create-element "div")))
|
||||
@@ -1412,7 +1422,15 @@
|
||||
(assert (dom-has-class? (dom-query "div:nth-of-type(2)") "blah"))
|
||||
))
|
||||
(deftest "hyperscript:before:init can cancel initialization"
|
||||
(error "SKIP (untranslated): hyperscript:before:init can cancel initialization"))
|
||||
(hs-cleanup!)
|
||||
(let ((wa (dom-create-element "div")))
|
||||
(dom-listen wa "hyperscript:before:init"
|
||||
(fn (e) (host-call e "preventDefault")))
|
||||
(dom-set-inner-html wa "<div _=\"on click add .foo\"></div>")
|
||||
(hs-boot-subtree! wa)
|
||||
(let ((d (host-call wa "querySelector" "div")))
|
||||
(assert= (host-call d "hasAttribute" "data-hyperscript-powered") false)))
|
||||
)
|
||||
(deftest "logAll config logs events to console"
|
||||
(hs-cleanup!)
|
||||
(hs-clear-log-captured!)
|
||||
|
||||
Reference in New Issue
Block a user