;; 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: set (25 tests — 24 runnable)"
    (p :style "color:#57534e;margin-bottom:1rem" "Live cards for the upstream set tests. 24 of 25 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-dom))"
        :style "color:#7c3aed" "dom"))
    (div :style "display:flex;flex-direction:column"
      (~hyperscript/hs-test-card
  :name "can set properties"
  :html "<div id='d1' _='on click set #d1.innerHTML to \"foo\"'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :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 set #d1.innerHTML to \\\"foo\\\"\")
    (dom-append sandbox _el-d1)
    (hs-activate! _el-d1)
    (dom-dispatch _el-d1 \"click\" nil)
    (assert= (dom-inner-html _el-d1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set indirect properties"
  :html "<div id='d1' _='on click set innerHTML of #d1 to \"foo\"'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :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 set innerHTML of #d1 to \\\"foo\\\"\")
    (dom-append sandbox _el-d1)
    (hs-activate! _el-d1)
    (dom-dispatch _el-d1 \"click\" nil)
    (assert= (dom-inner-html _el-d1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set complex indirect properties lhs"
  :html "<div _='on click set parentNode.innerHTML of #d1 to \"foo\"'><div id='d1'></div></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-d1 (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set parentNode.innerHTML of #d1 to \\\"foo\\\"\")
    (dom-set-attr _el-d1 \"id\" \"d1\")
    (dom-append sandbox _el-div)
    (dom-append _el-div _el-d1)
    (hs-activate! _el-div)
    (dom-dispatch _el-d1 \"click\" nil)
    (assert= (dom-inner-html _el-d1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set complex indirect properties rhs"
  :html "<div _='on click set innerHTML of #d1.parentNode to \"foo\"'><div id='d1'></div></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-d1 (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set innerHTML of #d1.parentNode to \\\"foo\\\"\")
    (dom-set-attr _el-d1 \"id\" \"d1\")
    (dom-append sandbox _el-div)
    (dom-append _el-div _el-d1)
    (hs-activate! _el-div)
    (dom-dispatch _el-d1 \"click\" nil)
    (assert= (dom-inner-html _el-d1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set chained indirect properties"
  :html "<div _='on click set the innerHTML of the parentNode of #d1 to \"foo\"'><div id='d1'></div></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-d1 (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set the innerHTML of the parentNode of #d1 to \\\"foo\\\"\")
    (dom-set-attr _el-d1 \"id\" \"d1\")
    (dom-append sandbox _el-div)
    (dom-append _el-div _el-d1)
    (hs-activate! _el-div)
    (dom-dispatch _el-d1 \"click\" nil)
    (assert= (dom-inner-html _el-d1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set styles"
  :html "<div _='on click set my.style.color to \"red\"'>lolwat</div>"
  :action "d1.click()"
  :check "d1.style.color.should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set my.style.color to \\\"red\\\"\")
    (dom-set-inner-html _el-div \"lolwat\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-style _el-div \"color\") \"red\")
  ))")
(~hyperscript/hs-test-card
  :name "can set javascript globals"
  :html "<div _='on click set window.temp to \"red\"'>lolwat</div>"
  :action "d1.click()"
  :check "window[\"temp\"].should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set window.temp to \\\"red\\\"\")
    (dom-set-inner-html _el-div \"lolwat\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip window[\"temp\"].should.equal(\"red\")
  ))")
(~hyperscript/hs-test-card
  :name "can set local variables"
  :html "<div id='d1' _='on click set newVar to \"foo\" then                                    put newVar into #d1.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :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 set newVar to \\\"foo\\\" then put newVar into #d1.innerHTML\")
    (dom-append sandbox _el-d1)
    (hs-activate! _el-d1)
    (dom-dispatch _el-d1 \"click\" nil)
    (assert= (dom-inner-html _el-d1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into id ref"
  :html "<div id='d1' _='on click set #d1.innerHTML to \"foo\"'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :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 set #d1.innerHTML to \\\"foo\\\"\")
    (dom-append sandbox _el-d1)
    (hs-activate! _el-d1)
    (dom-dispatch _el-d1 \"click\" nil)
    (assert= (dom-inner-html _el-d1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into class ref"
  :html "<div class='divs' _='on click set .divs.innerHTML to \"foo\"'></div> | <div class='divs''></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\") && d2.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-div1 (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set .divs.innerHTML to \\\"foo\\\"\")
    (dom-add-class _el-div1 \"divs\")
    (dom-append sandbox _el-div)
    (dom-append sandbox _el-div1)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
    (assert= (dom-inner-html _el-div1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into attribute ref"
  :html "<div class='divs' _='on click set @bar to \"foo\"'></div>"
  :action "d1.click()"
  :check "d1.getAttribute(\"bar\").should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set @bar to \\\"foo\\\"\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-attr _el-div \"bar\") \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into indirect attribute ref"
  :html "<div class='divs' _=\"on click set #div2's @bar to 'foo'\"></div> | <div id='div2'></div>"
  :action "d1.click()"
  :check "d2.getAttribute(\"bar\").should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-div2 (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set #div2's @bar to 'foo'\")
    (dom-set-attr _el-div2 \"id\" \"div2\")
    (dom-append sandbox _el-div)
    (dom-append sandbox _el-div2)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-attr _el-div2 \"bar\") \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into indirect attribute ref 2"
  :html "<div class='divs' _=\"on click set #div2's @bar to 'foo'\"></div> | <div id='div2'></div>"
  :action "d1.click()"
  :check "d2.getAttribute(\"bar\").should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-div2 (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set #div2's @bar to 'foo'\")
    (dom-set-attr _el-div2 \"id\" \"div2\")
    (dom-append sandbox _el-div)
    (dom-append sandbox _el-div2)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-attr _el-div2 \"bar\") \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into indirect attribute ref 3"
  :html "<div class='divs' _=\"on click set @bar of #div2 to 'foo'\"></div> | <div id='div2'></div>"
  :action "d1.click()"
  :check "d2.getAttribute(\"bar\").should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-div2 (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set @bar of #div2 to 'foo'\")
    (dom-set-attr _el-div2 \"id\" \"div2\")
    (dom-append sandbox _el-div)
    (dom-append sandbox _el-div2)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-attr _el-div2 \"bar\") \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into style ref"
  :html "<div class='divs' _='on click set *color to \"red\"'></div>"
  :action "d1.click()"
  :check "d1.style[\"color\"].should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set *color to \\\"red\\\"\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip d1.style[\"color\"].should.equal(\"red\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into indirect style ref"
  :html "<div class='divs' _=\"on click set #div2's *color to 'red'\"></div> | <div id='div2'></div>"
  :action "d1.click()"
  :check "d2.style[\"color\"].should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-div2 (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set #div2's *color to 'red'\")
    (dom-set-attr _el-div2 \"id\" \"div2\")
    (dom-append sandbox _el-div)
    (dom-append sandbox _el-div2)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip d2.style[\"color\"].should.equal(\"red\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into indirect style ref 2"
  :html "<div class='divs' _=\"on click set #div2's *color to 'red'\"></div> | <div id='div2'></div>"
  :action "d1.click()"
  :check "d2.style[\"color\"].should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-div2 (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set #div2's *color to 'red'\")
    (dom-set-attr _el-div2 \"id\" \"div2\")
    (dom-append sandbox _el-div)
    (dom-append sandbox _el-div2)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip d2.style[\"color\"].should.equal(\"red\")
  ))")
(~hyperscript/hs-test-card
  :name "can set into indirect style ref 3"
  :html "<div class='divs' _=\"on click set *color of #div2 to 'red'\"></div> | <div id='div2'></div>"
  :action "d1.click()"
  :check "d2.style[\"color\"].should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-div2 (dom-create-element \"div\")))
    (dom-add-class _el-div \"divs\")
    (dom-set-attr _el-div \"_\" \"on click set *color of #div2 to 'red'\")
    (dom-set-attr _el-div2 \"id\" \"div2\")
    (dom-append sandbox _el-div)
    (dom-append sandbox _el-div2)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip d2.style[\"color\"].should.equal(\"red\")
  ))")
(~hyperscript/hs-test-card
  :name "set waits on promises"
  :html "<div id='d1' _='on click set #d1.innerHTML to promiseAString()'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"\") && d1.innerHTML.should.equal(\"foo\")"
  :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 set #d1.innerHTML to promiseAString()\")
    (dom-append sandbox _el-d1)
    (hs-activate! _el-d1)
    (dom-dispatch _el-d1 \"click\" nil)
    (assert= (dom-inner-html _el-d1) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "can set many properties at once with object literal"
  :html "<div _='on click set {bar: 2, baz: 3} on obj'></div>"
  :action "(see body)"
  :check "obj.should.deep.equal({ foo: 1, bar: 2, baz: 3 })"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))")
(~hyperscript/hs-test-card
  :name "can set props w/ array access syntax"
  :html "<div _='on click set my style[\"color\"] to \"red\"'>lolwat</div>"
  :action "d1.click()"
  :check "d1.style.color.should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set my style[\\\"color\\\"] to \\\"red\\\"\")
    (dom-set-inner-html _el-div \"lolwat\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-style _el-div \"color\") \"red\")
  ))")
(~hyperscript/hs-test-card
  :name "can set props w/ array access syntax and var"
  :html "<div _='on click set foo to \"color\" then set my style[foo] to \"red\"'>lolwat</div>"
  :action "d1.click()"
  :check "d1.style.color.should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set foo to \\\"color\\\" then set my style[foo] to \\\"red\\\"\")
    (dom-set-inner-html _el-div \"lolwat\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-style _el-div \"color\") \"red\")
  ))")
(~hyperscript/hs-test-card
  :name "can set arrays w/ array access syntax"
  :html "<div _='on click set arr to [1, 2, 3] set arr[0] to \"red\" set my *color to arr[0]'>lolwat</div>"
  :action "d1.click()"
  :check "d1.style.color.should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set arr to [1, 2, 3] set arr[0] to \\\"red\\\" set my *color to arr[0]\")
    (dom-set-inner-html _el-div \"lolwat\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-style _el-div \"color\") \"red\")
  ))")
(~hyperscript/hs-test-card
  :name "can set arrays w/ array access syntax and var"
  :html "<div _='on click set arr to [1, 2, 3] set idx to 0 set arr[idx] to \"red\" set my *color to arr[0]'>lolwat</div>"
  :action "d1.click()"
  :check "d1.style.color.should.equal(\"red\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set arr to [1, 2, 3] set idx to 0 set arr[idx] to \\\"red\\\" set my *color to arr[0]\")
    (dom-set-inner-html _el-div \"lolwat\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-get-style _el-div \"color\") \"red\")
  ))")
(~hyperscript/hs-test-card
  :name "handles set url regression properly"
  :html "<div _='on click set trackingcode to `foo`         set pdfurl to `https://yyy.xxxxxx.com/path/out/${trackingcode}.pdf`         put pdfurl into me'>lolwat</div>"
  :action "d1.click()"
  :check "d1.innerText.should.equal(\"https://yyy.xxxxxx.com/path/out/foo.pdf\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click set trackingcode to `foo` then set pdfurl to `https://yyy.xxxxxx.com/path/out/${trackingcode}.pdf` then put pdfurl into me\")
    (dom-set-inner-html _el-div \"lolwat\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip d1.innerText.should.equal(\"https://yyy.xxxxxx.com/path/out/f
  ))"))))
