Migrates hyperscript demo/reference pages from grouped index files into one-per-page directory layout. Each gallery-<topic>/index.sx is a single defpage with its own demo, matching the one-per-file convention used elsewhere in sx/sx/applications/. Covers: control (call/go/if/log/repeat/settle), dom (add/append/empty/ focus/hide/measure/morph/put/remove/reset/scroll/set/show/swap/take/ toggle), events (asyncError/bootstrap/dialog/fetch/halt/init/on/pick/ send/socket/tell/wait/when), expressions (asExpression/attributeRef/ closest/collectionExpressions/comparisonOperator/default/in/increment/ logicalOperator/mathOperator/no/objectLiteral/queryRef/select/splitJoin), language (askAnswer/assignableElements/component/cookies/def/dom-scope/ evalStatically/js/parser/relativePositionalExpression/scoping), and reactivity (bind/live/liveTemplate/reactive-properties/resize/transition). Adds _islands/hs-test-card.sx — a shared island for hyperscript demos. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
92 lines
3.9 KiB
Plaintext
92 lines
3.9 KiB
Plaintext
;; AUTO-GENERATED from spec/tests/hyperscript-upstream-tests.json
|
|
;; DO NOT EDIT — regenerate with:
|
|
;; python3 tests/playwright/generate-sx-tests.py --emit-pages
|
|
|
|
(defcomp ()
|
|
(~docs/page :title "Hyperscript: call (6 tests — 6 runnable)"
|
|
(p :style "color:#57534e;margin-bottom:1rem" "Live cards for the upstream call tests. 6 of 6 are reproducible in-browser; the remainder show their source for reference.")
|
|
(p :style "color:#78716c;font-size:0.875rem;margin-bottom:1rem"
|
|
"Theme: " (a :href "/sx/(applications.(hyperscript.gallery-control))"
|
|
:style "color:#7c3aed" "control"))
|
|
(div :style "display:flex;flex-direction:column"
|
|
(~hyperscript/hs-test-card
|
|
:name "can call javascript instance functions"
|
|
:html "<div id='d1' _='on click call document.getElementById(\"d1\") then put it into window.results'></div>"
|
|
:action "d1.click()"
|
|
:check "value.should.equal(d1)"
|
|
:run-src "(fn (sandbox)
|
|
(let ((_el-d1 (dom-create-element \"div\")))
|
|
(dom-set-attr _el-d1 \"id\" \"d1\")
|
|
(dom-set-attr _el-d1 \"_\" \"on click call document.getElementById(\\\"d1\\\") then put it into window.results\")
|
|
(dom-append sandbox _el-d1)
|
|
(hs-activate! _el-d1)
|
|
(dom-dispatch _el-d1 \"click\" nil)
|
|
;; SKIP check: skip value.should.equal(d1)
|
|
))")
|
|
(~hyperscript/hs-test-card
|
|
:name "can call global javascript functions"
|
|
:html "<div _='on click call globalFunction(\"foo\")'></div>"
|
|
:action "div.click()"
|
|
:check "\"foo\".should.equal(calledWith)"
|
|
:run-src "(fn (sandbox)
|
|
(let ((_el-div (dom-create-element \"div\")))
|
|
(dom-set-attr _el-div \"_\" \"on click call globalFunction(\\\"foo\\\")\")
|
|
(dom-append sandbox _el-div)
|
|
(hs-activate! _el-div)
|
|
(dom-dispatch _el-div \"click\" nil)
|
|
;; SKIP check: skip \"foo\".should.equal(calledWith)
|
|
))")
|
|
(~hyperscript/hs-test-card
|
|
:name "can call no argument functions"
|
|
:html "<div _='on click call globalFunction()'></div>"
|
|
:action "div.click()"
|
|
:check "called.should.equal(true)"
|
|
:run-src "(fn (sandbox)
|
|
(let ((_el-div (dom-create-element \"div\")))
|
|
(dom-set-attr _el-div \"_\" \"on click call globalFunction()\")
|
|
(dom-append sandbox _el-div)
|
|
(hs-activate! _el-div)
|
|
(dom-dispatch _el-div \"click\" nil)
|
|
;; SKIP check: skip called.should.equal(true)
|
|
))")
|
|
(~hyperscript/hs-test-card
|
|
:name "can call functions w/ underscores"
|
|
:html "<div _='on click call global_function()'></div>"
|
|
:action "div.click()"
|
|
:check "called.should.equal(true)"
|
|
:run-src "(fn (sandbox)
|
|
(let ((_el-div (dom-create-element \"div\")))
|
|
(dom-set-attr _el-div \"_\" \"on click call global_function()\")
|
|
(dom-append sandbox _el-div)
|
|
(hs-activate! _el-div)
|
|
(dom-dispatch _el-div \"click\" nil)
|
|
;; SKIP check: skip called.should.equal(true)
|
|
))")
|
|
(~hyperscript/hs-test-card
|
|
:name "can call functions w/ dollar signs"
|
|
:html "<div _='on click call $()'></div>"
|
|
:action "div.click()"
|
|
:check "called.should.equal(true)"
|
|
:run-src "(fn (sandbox)
|
|
(let ((_el-div (dom-create-element \"div\")))
|
|
(dom-set-attr _el-div \"_\" \"on click call $()\")
|
|
(dom-append sandbox _el-div)
|
|
(hs-activate! _el-div)
|
|
(dom-dispatch _el-div \"click\" nil)
|
|
;; SKIP check: skip called.should.equal(true)
|
|
))")
|
|
(~hyperscript/hs-test-card
|
|
:name "call functions that return promises are waited on"
|
|
:html "<div _='on click call promiseAnInt() then put it into my.innerHTML'></div>"
|
|
:action "div.click()"
|
|
:check "div.innerText.should.equal(\"\") && div.innerText.should.equal(\"42\")"
|
|
:run-src "(fn (sandbox)
|
|
(let ((_el-div (dom-create-element \"div\")))
|
|
(dom-set-attr _el-div \"_\" \"on click call promiseAnInt() then put it into my.innerHTML\")
|
|
(dom-append sandbox _el-div)
|
|
(hs-activate! _el-div)
|
|
(dom-dispatch _el-div \"click\" nil)
|
|
;; SKIP check: skip div.innerText.should.equal(\"\")
|
|
;; SKIP check: skip div.innerText.should.equal(\"42\")
|
|
))"))))
|