Implicit then, between, starts/ends with — 339/831 (41%)

Biggest win: HS sources from upstream HTML had newlines replaced with
spaces, losing command separation. Now multi-space sequences become
'then' keywords, matching _hyperscript's implicit newline-as-separator
behavior. +42 tests passing.

Parser: 'is between X and Y', 'is not between', 'starts with',
'ends with' comparison operators.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 23:15:01 +00:00
parent 6e38a2e1e1
commit 299f3e748d
3 changed files with 120 additions and 114 deletions

View File

@@ -220,7 +220,7 @@
(deftest "can add a value to an array"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :arr to [1,2,3] add 4 to :arr put :arr as String into me")
(dom-set-attr _el-div "_" "on click then set :arr to [1,2,3] then add 4 to :arr then put :arr as String into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -229,7 +229,7 @@
(deftest "can add a value to a set"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :s to [] as Set add 'a' to :s add 'b' to :s add 'a' to :s put :s.size into me")
(dom-set-attr _el-div "_" "on click then set :s to [] as Set then add 'a' to :s then add 'b' to :s then add 'a' to :s then put :s.size into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -379,7 +379,7 @@
(deftest "can remove a value from an array"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :arr to [1,2,3,4] remove 3 from :arr put :arr as String into me")
(dom-set-attr _el-div "_" "on click then set :arr to [1,2,3,4] then remove 3 from :arr then put :arr as String into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -388,7 +388,7 @@
(deftest "can remove a value from a set"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :s to ['a','b','c'] as Set remove 'b' from :s put :s.size into me")
(dom-set-attr _el-div "_" "on click then set :s to ['a','b','c'] as Set then remove 'b' from :s then put :s.size into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -782,7 +782,7 @@
(hs-cleanup!)
(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-set-attr _el-d1 "_" "on click set newVar to \"foo\" then put newVar into #d1.innerHTML")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-dispatch _el-d1 "click" nil)
@@ -954,7 +954,7 @@
(deftest "handles set url regression properly"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set trackingcode to `foo` set pdfurl to `https://yyy.xxxxxx.com/path/out/${trackingcode}.pdf` put pdfurl into me")
(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-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1064,7 +1064,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click put \"foo\" into newVar then put newVar into #d1.innerHTML")
(dom-set-attr _el-d1 "_" "on click put \"foo\" into newVar then put newVar into #d1.innerHTML")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-dispatch _el-d1 "click" nil)
@@ -1346,7 +1346,7 @@
(deftest "can put at start of an array"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :arr to [2,3] put 1 at start of :arr put :arr as String into me")
(dom-set-attr _el-div "_" "on click then set :arr to [2,3] then put 1 at start of :arr then put :arr as String into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1355,7 +1355,7 @@
(deftest "can put at end of an array"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :arr to [1,2] put 3 at end of :arr put :arr as String into me")
(dom-set-attr _el-div "_" "on click then set :arr to [1,2] then put 3 at end of :arr then put :arr as String into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1377,7 +1377,7 @@
(deftest "hide element then show element retains original display"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click 1 hide on click 2 show")
(dom-set-attr _el-div "_" "on click 1 hide then on click 2 show")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1518,7 +1518,7 @@
(deftest "basic true branch works with multiple commands"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click if true log me then put \"foo\" into me.innerHTML")
(dom-set-attr _el-div "_" "on click if true log me then put \"foo\" into me.innerHTML")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1581,7 +1581,7 @@
(deftest "basic else if branch works with end"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click if false else if true put \"foo\" into me.innerHTML end")
(dom-set-attr _el-div "_" "on click if false then else if true put \"foo\" into me.innerHTML end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1608,7 +1608,7 @@
(deftest "triple else if branch works with end"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click if false else if false else put \"foo\" into me.innerHTML end")
(dom-set-attr _el-div "_" "on click if false then else if false then else put \"foo\" into me.innerHTML end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1617,7 +1617,7 @@
(deftest "basic else branch works with multiple commands"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click if false put \"bar\" into me.innerHTML else log me then put \"foo\" into me.innerHTML")
(dom-set-attr _el-div "_" "on click if false put \"bar\" into me.innerHTML then else log me then put \"foo\" into me.innerHTML")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1653,7 +1653,7 @@
(deftest "if properly supports nested if statements and end block"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click n if window.tmp thenn put \"foo\" into men else if not window.tmp thenn // do nothingn endn catch en // just here for the parsing...n")
(dom-set-attr _el-div "_" "on click n then if window.tmp thenn then put \"foo\" into men then else if not window.tmp thenn then // do nothingn then endn then catch en then // just here for the parsing...n")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1663,7 +1663,7 @@
(deftest "if on new line does not join w/ else"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click n if window.tmp thenn elsen if window.tmp then endn put \"foo\" into men endn")
(dom-set-attr _el-div "_" "on click n then if window.tmp thenn then elsen then if window.tmp then endn then put \"foo\" into men then endn then")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1679,7 +1679,7 @@
(deftest "basic for loop works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat for x in [1, 2, 3] put x at end of me end")
(dom-set-attr _el-div "_" "on click repeat for x in [1, 2, 3] then put x at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1688,7 +1688,7 @@
(deftest "basic for loop with null works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat for x in null put x at end of me end")
(dom-set-attr _el-div "_" "on click repeat for x in null then put x at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1697,7 +1697,7 @@
(deftest "waiting in for loop works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat for x in [1, 2, 3]n log me put x at end of men wait 1msn end")
(dom-set-attr _el-div "_" "on click repeat for x in [1, 2, 3]n then log me then put x at end of men then wait 1msn then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1706,7 +1706,7 @@
(deftest "basic raw for loop works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click for x in [1, 2, 3] put x at end of me end")
(dom-set-attr _el-div "_" "on click for x in [1, 2, 3] then put x at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1715,7 +1715,7 @@
(deftest "basic raw for loop works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click for x in null put x at end of me end")
(dom-set-attr _el-div "_" "on click for x in null then put x at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1724,7 +1724,7 @@
(deftest "waiting in raw for loop works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click for x in [1, 2, 3]n put x at end of men wait 1msn end")
(dom-set-attr _el-div "_" "on click for x in [1, 2, 3]n then put x at end of men then wait 1msn then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1757,7 +1757,7 @@
(deftest "basic in loop works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat in [1, 2, 3] put it at end of me end")
(dom-set-attr _el-div "_" "on click repeat in [1, 2, 3] then put it at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1766,7 +1766,7 @@
(deftest "index syntax works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat for x in [\"a\", \"ab\", \"abc\"] index i put x + i at end of me end")
(dom-set-attr _el-div "_" "on click repeat for x in [\"a\", \"ab\", \"abc\"] index i then put x + i at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1775,7 +1775,7 @@
(deftest "indexed by syntax works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat for x in [\"a\", \"ab\", \"abc\"] indexed by i put x + i at end of me end")
(dom-set-attr _el-div "_" "on click repeat for x in [\"a\", \"ab\", \"abc\"] indexed by i then put x + i at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1843,7 +1843,7 @@
(deftest "basic times loop works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat 3 times put \"a\" at end of me end")
(dom-set-attr _el-div "_" "on click repeat 3 times then put \"a\" at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1852,7 +1852,7 @@
(deftest "times loop with expression works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat 3 + 3 times put \"a\" at end of me end")
(dom-set-attr _el-div "_" "on click repeat 3 + 3 times then put \"a\" at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1861,7 +1861,7 @@
(deftest "loop continue works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat 2 times for x in ['A', 'B', 'C', 'D'] if (x != 'D') then put 'success ' + x + '. ' at end of me continue put 'FAIL!!. ' at end of me end put 'expected D. ' at end of me end end")
(dom-set-attr _el-div "_" "on click then repeat 2 times then for x in ['A', 'B', 'C', 'D'] then if (x != 'D') then put 'success ' + x then + '. ' at end of me then continue then put 'FAIL!!. ' at end of me then end then put 'expected D. ' at end of me then end then end then")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1870,7 +1870,7 @@
(deftest "loop break works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat 2 times for x in ['A', 'B', 'C', 'D'] if x is 'C' break end put x at end of me end end")
(dom-set-attr _el-div "_" "on click then repeat 2 times then for x in ['A', 'B', 'C', 'D'] then if x is 'C' then break then end then put x at end of me then end then end then")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1879,7 +1879,7 @@
(deftest "basic raw for loop with null works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click for x in null put x at end of me end")
(dom-set-attr _el-div "_" "on click for x in null then put x at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1888,7 +1888,7 @@
(deftest "basic property for loop works"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set x to {foo:1, bar:2, baz:3} for prop in x put x[prop] at end of me end")
(dom-set-attr _el-div "_" "on click set x to {foo:1, bar:2, baz:3} then for prop in x then put x[prop] at end of me then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1897,7 +1897,7 @@
(deftest "bottom-tested repeat until"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set x to 0 repeat set x to until x is 3 end put x into me")
(dom-set-attr _el-div "_" "on click set x to 0 then repeat then set x to then until x is 3 end then put x into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1906,7 +1906,7 @@
(deftest "bottom-tested repeat while"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set x to 0 repeat set x to while x < 3 end put x into me")
(dom-set-attr _el-div "_" "on click set x to 0 then repeat then set x to then while x < 3 end then put x into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1915,7 +1915,7 @@
(deftest "bottom-tested loop always runs at least once"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set x to 0 repeat set x to until true end put x into me")
(dom-set-attr _el-div "_" "on click set x to 0 then repeat then set x to then until true end then put x into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1924,7 +1924,7 @@
(deftest "break exits a simple repeat loop"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set x to 0 repeat 10 times set x to x + 1 if x is 3 break end end put x into me")
(dom-set-attr _el-div "_" "on click then set x to 0 then repeat 10 times then set x to x + 1 then if x is 3 break end then end then put x into me then")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1933,7 +1933,7 @@
(deftest "continue skips rest of iteration in simple repeat loop"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat for x in [1, 2, 3, 4, 5] if x is 3 continue end put x at end of me end")
(dom-set-attr _el-div "_" "on click then repeat for x in [1, 2, 3, 4, 5] then if x is 3 continue end then put x at end of me then end then")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1942,7 +1942,7 @@
(deftest "break exits a for-in loop"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click repeat for x in [1, 2, 3, 4, 5] if x is 4 break end put x at end of me end")
(dom-set-attr _el-div "_" "on click then repeat for x in [1, 2, 3, 4, 5] then if x is 4 break end then put x at end of me then end then")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1951,7 +1951,7 @@
(deftest "break exits a while loop"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set x to 0 repeat while x < 100 set x to x + 1 if x is 5 break end end put x into me")
(dom-set-attr _el-div "_" "on click then set x to 0 then repeat while x < 100 then set x to x + 1 then if x is 5 break end then end then put x into me then")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1973,7 +1973,7 @@
(deftest "can wait on time"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click add .foo then wait 20ms then add .bar")
(dom-set-attr _el-div "_" "on click then add .foo then wait 20ms then add .bar")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1983,7 +1983,7 @@
(deftest "can wait on event"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click add .foo then wait for foo then add .bar")
(dom-set-attr _el-div "_" "on click then add .foo then wait for foo then add .bar")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -1994,7 +1994,7 @@
(deftest "waiting on an event sets 'it' to the event"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click wait for foo then put its.detail into me")
(dom-set-attr _el-div "_" "on click wait for foo then put its.detail into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -2004,7 +2004,7 @@
(deftest "can destructure properties in a wait"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click wait for foo(bar) then put bar into me")
(dom-set-attr _el-div "_" "on click wait for foo(bar) then put bar into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -2016,7 +2016,7 @@
(let ((_el-d2 (dom-create-element "div")) (_el-div (dom-create-element "div")))
(dom-set-attr _el-d2 "id" "d2")
(dom-append (dom-body) _el-d2)
(dom-set-attr _el-div "_" "on click add .foo then wait for foo from #d2 then add .bar")
(dom-set-attr _el-div "_" "on click then add .foo then wait for foo from #d2 then add .bar")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -2029,7 +2029,7 @@
(let ((_el-d2 (dom-create-element "div")) (_el-div (dom-create-element "div")))
(dom-set-attr _el-d2 "id" "d2")
(dom-append (dom-body) _el-d2)
(dom-set-attr _el-div "_" "on click add .foo then wait for foo or 0ms then add .bar")
(dom-set-attr _el-div "_" "on click then add .foo then wait for foo or 0ms then add .bar")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -2042,7 +2042,7 @@
(let ((_el-d2 (dom-create-element "div")) (_el-div (dom-create-element "div")))
(dom-set-attr _el-d2 "id" "d2")
(dom-append (dom-body) _el-d2)
(dom-set-attr _el-div "_" "on click add .foo then wait for foo or 0ms then add .bar")
(dom-set-attr _el-div "_" "on click then add .foo then wait for foo or 0ms then add .bar")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -2396,7 +2396,7 @@
(deftest "can transition with parameterized values"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set startWidth to 0 set endWidth to 100 transition width from (startWidth)px to (endWidth)px")
(dom-set-attr _el-div "_" "on click then set startWidth to 0 then set endWidth to 100 then transition width from (startWidth)px to (endWidth)px")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -2465,7 +2465,7 @@
(deftest "can transition on another element no element prefix with it"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")) (_el-foo (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click get #foo then transition its width from 0px to 100px")
(dom-set-attr _el-div "_" "on click get then #foo then transition its width from 0px to 100px")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-set-attr _el-foo "id" "foo")
@@ -2524,7 +2524,7 @@
(deftest "can use initial to transition to original value"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click 1 transition my *width to 100px on click 2 transition my *width to initial")
(dom-set-attr _el-div "_" "on click 1 transition my *width to 100px then on click 2 transition my *width to initial")
(dom-set-attr _el-div "style" "width: 10px")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
@@ -2636,7 +2636,7 @@
(hs-cleanup!)
(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-set-attr _el-d1 "_" "on click call document.getElementById(\"d1\") then put it into window.results")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-dispatch _el-d1 "click" nil)
@@ -3116,7 +3116,7 @@
(deftest "can append a string to another string"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set value to 'Hello there.' then append ' General Kenobi.' to value then set my.innerHTML to value")
(dom-set-attr _el-div "_" "on click then set value to 'Hello there.' then append ' General Kenobi.' to value then set my.innerHTML to value")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -3125,7 +3125,7 @@
(deftest "can append a value into an array"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set value to [1,2,3] append 4 to value set my.innerHTML to value as String")
(dom-set-attr _el-div "_" "on click then set value to [1,2,3] then append 4 to value then set my.innerHTML to value as String")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -3134,7 +3134,7 @@
(deftest "can append a value to 'it'"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set result to [1,2,3] append 4 put it as String into me")
(dom-set-attr _el-div "_" "on click then set result to [1,2,3] then append 4 then put it as String into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -3143,7 +3143,7 @@
(deftest "can append a value to a DOM node"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click append '<span>This is my inner HTML</span>' to me append '<b>With Tags</b>' to me")
(dom-set-attr _el-div "_" "on click then append '<span>This is my inner HTML</span>' to me then append '<b>With Tags</b>' to me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -3153,7 +3153,7 @@
(hs-cleanup!)
(let ((_el-content (dom-create-element "div")))
(dom-set-attr _el-content "id" "content")
(dom-set-attr _el-content "_" "on click append 'Content' to #content")
(dom-set-attr _el-content "_" "on click then append 'Content' to #content")
(dom-append (dom-body) _el-content)
(hs-activate! _el-content)
(dom-dispatch _el-content "click" nil)
@@ -3162,7 +3162,7 @@
(deftest "can append a value to I"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click append 'Content' to I")
(dom-set-attr _el-div "_" "on click then append 'Content' to I")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -3233,7 +3233,7 @@
(deftest "can append a value to a set"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :s to [1,2] as Set append 3 to :s append 1 to :s put :s.size into me")
(dom-set-attr _el-div "_" "on click then set :s to [1,2] as Set then append 3 to :s then append 1 to :s then put :s.size into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -3247,7 +3247,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")) (_el-d2 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click add .foo tell #d2 add .bar")
(dom-set-attr _el-d1 "_" "on click then add .foo then tell #d2 then add .bar")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-set-attr _el-d2 "id" "d2")
@@ -3262,7 +3262,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")) (_el-d2 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click add .foo tell #d2 add .bar to me")
(dom-set-attr _el-d1 "_" "on click then add .foo then tell #d2 then add .bar to me")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-set-attr _el-d2 "id" "d2")
@@ -3277,7 +3277,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click add .foo tell <p/> in me add .bar")
(dom-set-attr _el-d1 "_" "on click then add .foo then tell <p/> in me then add .bar")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-dispatch _el-d1 "click" nil)
@@ -3294,7 +3294,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")) (_el-d2 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click tell #d2 add .bar end add .foo")
(dom-set-attr _el-d1 "_" "on click then tell #d2 then add .bar then end then add .foo")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-set-attr _el-d2 "id" "d2")
@@ -3309,7 +3309,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")) (_el-d2 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click tell null add .bar end add .foo")
(dom-set-attr _el-d1 "_" "on click then tell null then add .bar then end then add .foo")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-set-attr _el-d2 "id" "d2")
@@ -3324,7 +3324,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")) (_el-d2 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click tell #d2 add .bar to you")
(dom-set-attr _el-d1 "_" "on click then tell #d2 then add .bar to you")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-set-attr _el-d2 "id" "d2")
@@ -3337,7 +3337,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")) (_el-d2 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click tell #d2 put your innerText into me")
(dom-set-attr _el-d1 "_" "on click then tell #d2 then put your innerText into me")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-set-attr _el-d2 "id" "d2")
@@ -3351,7 +3351,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")) (_el-d2 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click tell #d2 put @foo into me")
(dom-set-attr _el-d1 "_" "on click then tell #d2 then put @foo into me")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-set-attr _el-d2 "id" "d2")
@@ -3590,7 +3590,7 @@
(deftest "can have multiple event handlers"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on foo put increment() into my.innerHTML end on bar put increment() into my.innerHTML")
(dom-set-attr _el-div "_" "on foo put increment() into my.innerHTML end then on bar put increment() into my.innerHTML")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "foo" nil)
@@ -3603,7 +3603,7 @@
(deftest "can have multiple event handlers, no end"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on foo put increment() into my.innerHTML on bar put increment() into my.innerHTML")
(dom-set-attr _el-div "_" "on foo put increment() into my.innerHTML then on bar put increment() into my.innerHTML")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "foo" nil)
@@ -3747,7 +3747,7 @@
(deftest "can mix ranges"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click 1 put \"one\" into my.innerHTML on click 3 put \"three\" into my.innerHTML on click 2 put \"two\" into my.innerHTML")
(dom-set-attr _el-div "_" "on click 1 put \"one\" into my.innerHTML then on click 3 put \"three\" into my.innerHTML then on click 2 put \"two\" into my.innerHTML")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -3910,7 +3910,7 @@
(deftest "async exceptions don't kill the event queue"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click increment :x if :x is 1 wait 1ms then throw \"bar\" otherwise put \"success\" into me end catch e put e into me")
(dom-set-attr _el-button "_" "on click then increment :x then if :x is 1 then wait 1ms then throw \"bar\" then otherwise then put \"success\" into me then end then catch e then put e into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3920,7 +3920,7 @@
(deftest "exceptions in catch block don't kill the event queue"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click increment :x if :x is 1 throw \"bar\" otherwise put \"success\" into me end catch e put e into me then throw e")
(dom-set-attr _el-button "_" "on click then increment :x then if :x is 1 then throw \"bar\" then otherwise then put \"success\" into me then end then catch e then put e into me then throw e")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3930,7 +3930,7 @@
(deftest "uncaught exceptions trigger 'exception' event"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" on exception(error) put error into me")
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" then on exception(error) put error into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3939,7 +3939,7 @@
(deftest "caught exceptions do not trigger 'exception' event"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" catch e log e on exception(error) put error into me")
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" then catch e log e then on exception(error) put error into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3948,7 +3948,7 @@
(deftest "rethrown exceptions trigger 'exception' event"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" catch e throw e on exception(error) put error into me")
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" then catch e throw e then on exception(error) put error into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3957,7 +3957,7 @@
(deftest "basic finally blocks work"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click throw \"bar\" finally put \"bar\" into me")
(dom-set-attr _el-button "_" "on click throw \"bar\" then finally put \"bar\" into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3966,7 +3966,7 @@
(deftest "finally blocks work when exception thrown in catch"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click throw \"bar\" catch e throw e finally put \"bar\" into me")
(dom-set-attr _el-button "_" "on click throw \"bar\" then catch e throw e then finally put \"bar\" into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3975,7 +3975,7 @@
(deftest "async basic finally blocks work"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click wait a tick then throw \"bar\" finally put \"bar\" into me")
(dom-set-attr _el-button "_" "on click wait a tick then throw \"bar\" then finally put \"bar\" into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3984,7 +3984,7 @@
(deftest "async finally blocks work when exception thrown in catch"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click wait a tick then throw \"bar\" catch e set :foo to \"foo\" then throw e finally put :foo + \"bar\" into me")
(dom-set-attr _el-button "_" "on click wait a tick then throw \"bar\" then catch e set :foo to \"foo\" then throw e then finally put :foo + \"bar\" into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -3993,7 +3993,7 @@
(deftest "async exceptions in finally block don't kill the event queue"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click increment :x finally if :x is 1 wait 1ms then throw \"bar\" otherwise put \"success\" into me end")
(dom-set-attr _el-button "_" "on click then increment :x then finally then if :x is 1 then wait 1ms then throw \"bar\" then otherwise then put \"success\" into me then end then")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -4003,7 +4003,7 @@
(deftest "exceptions in finally block don't kill the event queue"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click increment :x finally if :x is 1 throw \"bar\" otherwise put \"success\" into me end")
(dom-set-attr _el-button "_" "on click then increment :x then finally then if :x is 1 then throw \"bar\" then otherwise then put \"success\" into me then end then")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -4014,7 +4014,7 @@
(hs-cleanup!)
(let ((_el-#d1 (dom-create-element "div")))
(dom-set-attr _el-#d1 "id" "#d1")
(dom-set-attr _el-#d1 "_" "on click from #doesntExist throw \"bar\" on click put \"clicked\" into me")
(dom-set-attr _el-#d1 "_" "then on click from #doesntExist then throw \"bar\" then on click then put \"clicked\" into me")
(dom-append (dom-body) _el-#d1)
(hs-activate! _el-#d1)
(dom-dispatch _el-#d1 "click" nil)
@@ -4027,7 +4027,7 @@
(dom-append (dom-body) _el-d1)
(dom-set-attr _el-d2 "id" "d2")
(dom-append (dom-body) _el-d2)
(dom-set-attr _el-div "_" "on click from #d1 or click from #d2 increment @count then put @count into me")
(dom-set-attr _el-div "_" "then on click from #d1 or click from #d2 then increment @count then put @count into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-d1 "click" nil)
@@ -4056,7 +4056,7 @@
(deftest "caught exceptions do not trigger 'exception' event"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" catch e log e on exception(error) put error into me")
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" then catch e log e then on exception(error) put error into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -4065,7 +4065,7 @@
(deftest "rethrown exceptions trigger 'exception' event"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")))
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" catch e throw e on exception(error) put error into me")
(dom-set-attr _el-button "_" "on click put \"foo\" into me then throw \"bar\" then catch e throw e then on exception(error) put error into me")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-dispatch _el-button "click" nil)
@@ -4074,7 +4074,7 @@
(deftest "can ignore when target doesn\'t exist"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click from #doesntExist throw \"bar\" on click put \"clicked\" into me")
(dom-set-attr _el-div "_" "then on click from #doesntExist then throw \"bar\" then on click then put \"clicked\" into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -4087,7 +4087,7 @@
(deftest "can define an init block inline"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "init set my.foo to 42 end on click put my.foo into my.innerHTML")
(dom-set-attr _el-div "_" "init then set my.foo to 42 then end then on click put my.foo into my.innerHTML")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -4545,7 +4545,7 @@
(deftest "can empty an array"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :arr to [1,2,3] empty :arr put :arr.length into me")
(dom-set-attr _el-div "_" "on click then set :arr to [1,2,3] then empty :arr then put :arr.length into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -4554,7 +4554,7 @@
(deftest "can empty a set"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :s to [1,2,3] as Set empty :s put :s.size into me")
(dom-set-attr _el-div "_" "on click then set :s to [1,2,3] as Set then empty :s then put :s.size into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -4563,7 +4563,7 @@
(deftest "can empty a map"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "on click set :m to {a:1, b:2} as Map empty :m put :m.size into me")
(dom-set-attr _el-div "_" "on click then set :m to {a:1, b:2} as Map then empty :m then put :m.size into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -5211,7 +5211,7 @@
(dom-set-attr _el-name-input "type" "text")
(dom-set-attr _el-name-input "value" "Alice")
(dom-append (dom-body) _el-name-input)
(dom-set-attr _el-span "_" "bind $name and #name-input.value end when $name changes put it into me")
(dom-set-attr _el-span "_" "bind $name and #name-input.value end then when $name changes put it into me")
(dom-append (dom-body) _el-span)
(hs-activate! _el-span)
))
@@ -5236,14 +5236,14 @@
(dom-set-attr _el-city-input "type" "text")
(dom-set-attr _el-city-input "value" "Paris")
(dom-append (dom-body) _el-city-input)
(dom-set-attr _el-span "_" "bind $city to #city-input.value end when $city changes put it into me")
(dom-set-attr _el-span "_" "bind $city to #city-input.value end then when $city changes put it into me")
(dom-append (dom-body) _el-span)
(hs-activate! _el-span)
))
(deftest "shorthand on text input binds to value"
(hs-cleanup!)
(let ((_el-input (dom-create-element "input")) (_el-span (dom-create-element "span")))
(dom-set-attr _el-input "_" "bind $greeting to me end when $greeting changes put it into next <span/>")
(dom-set-attr _el-input "_" "bind $greeting to me end then when $greeting changes put it into next <span/>")
(dom-set-attr _el-input "type" "text")
(dom-set-attr _el-input "value" "hello")
(dom-append (dom-body) _el-input)
@@ -5649,7 +5649,7 @@
(deftest "derives a variable from a computed expression"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "live set $total to ($price * $qty) end when $total changes put it into me")
(dom-set-attr _el-div "_" "live set $total to ($price * $qty) end then when $total changes put it into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
@@ -5692,7 +5692,7 @@
(dom-set-attr _el-h "_" "when $doubleHeight changes put it into me")
(dom-append (dom-body) _el-h)
(hs-activate! _el-h)
(dom-set-attr _el-div "_" "live set $doubleWidth to ($width * 2) set $doubleHeight to ($height * 2) end")
(dom-set-attr _el-div "_" "live then set $doubleWidth to ($width * 2) then set $doubleHeight to ($height * 2) then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
@@ -5707,28 +5707,28 @@
(dom-set-attr _el-h "_" "when $doubleHeight changes put it into me")
(dom-append (dom-body) _el-h)
(hs-activate! _el-h)
(dom-set-attr _el-div "_" "live set $doubleWidth to ($width * 2) end live set $doubleHeight to ($height * 2)")
(dom-set-attr _el-div "_" "live set $doubleWidth to ($width * 2) end then live set $doubleHeight to ($height * 2)")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
(deftest "block form cascades inter-dependent commands"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "live set $subtotal to ($price * $qty) set $total to ($subtotal + $tax) end when $total changes put it into me")
(dom-set-attr _el-div "_" "live then set $subtotal to ($price * $qty) then set $total to ($subtotal + $tax) then end then when $total changes put it into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
(deftest "toggles a class based on a boolean variable"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "live if $isActive add .active to me else remove .active from me end end")
(dom-set-attr _el-div "_" "live then if $isActive add .active to me else remove .active from me end then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
(deftest "toggles display style based on a boolean variable"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "live if $isVisible set *display to 'block' else set *display to 'none' end end")
(dom-set-attr _el-div "_" "live then if $isVisible set *display to 'block' else set *display to 'none' end then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
@@ -5742,28 +5742,28 @@
(deftest "conditional branch only tracks the active dependency"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "live if $showFirst put $firstName into me else put $lastName into me end end")
(dom-set-attr _el-div "_" "live then if $showFirst put $firstName into me else put $lastName into me end then end")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
(deftest "multiple live on same element work independently"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "live set my @data-name to $firstName end live set my @data-age to $age")
(dom-set-attr _el-div "_" "live set my @data-name to $firstName end then live set my @data-age to $age")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
(deftest "live and when on same element do not interfere"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "live set my @data-status to $status end when $status changes put 'Status: ' + it into me")
(dom-set-attr _el-div "_" "live set my @data-status to $status end then when $status changes put 'Status: ' + it into me")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
(deftest "bind and live on same element do not interfere"
(hs-cleanup!)
(let ((_el-input (dom-create-element "input")) (_el-span (dom-create-element "span")))
(dom-set-attr _el-input "_" "bind $username to me end live set my @data-mirror to $username")
(dom-set-attr _el-input "_" "bind $username to me end then live set my @data-mirror to $username")
(dom-set-attr _el-input "type" "text")
(dom-set-attr _el-input "value" "alice")
(dom-append (dom-body) _el-input)
@@ -5927,7 +5927,7 @@
(deftest "detects changes from :element variable"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "init set :count to 0 end when :count changes put it into me end on click increment :count")
(dom-set-attr _el-div "_" "init set :count to 0 end then when :count changes put it into me end then on click increment :count")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -6033,14 +6033,14 @@
(deftest "supports multiple when features on the same element"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "when $left changes put it into my @data-left end when $right changes put it into my @data-right")
(dom-set-attr _el-div "_" "when $left changes put it into my @data-left end then when $right changes put it into my @data-right")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
(deftest "works with on handlers that modify the watched variable"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "init set :label to 'initial' end when :label changes put it into me end on click set :label to 'clicked'")
(dom-set-attr _el-div "_" "init set :label to 'initial' end then when :label changes put it into me end then on click set :label to 'clicked'")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch _el-div "click" nil)
@@ -6049,7 +6049,7 @@
(deftest "does not cross-trigger on unrelated variable writes"
(hs-cleanup!)
(let ((_el-div (dom-create-element "div")))
(dom-set-attr _el-div "_" "when $trigger changes increment :count put :count into me set $other to 'side-effect'")
(dom-set-attr _el-div "_" "when $trigger changes then increment :count then put :count into me then set $other to 'side-effect'")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
))
@@ -6064,11 +6064,11 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")) (_el-d2 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "init set :value to 'A' end when :value changes put it into me end on click set :value to 'A-clicked'")
(dom-set-attr _el-d1 "_" "init set :value to 'A' end then when :value changes put it into me end then on click set :value to 'A-clicked'")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-set-attr _el-d2 "id" "d2")
(dom-set-attr _el-d2 "_" "init set :value to 'B' end when :value changes put it into me end on click set :value to 'B-clicked'")
(dom-set-attr _el-d2 "_" "init set :value to 'B' end then when :value changes put it into me end then on click set :value to 'B-clicked'")
(dom-append (dom-body) _el-d2)
(hs-activate! _el-d2)
(dom-dispatch (dom-query-by-id "d1") "click" nil)
@@ -6252,7 +6252,7 @@
(deftest "rejected promise stops execution"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")) (_el-out (dom-create-element "div")))
(dom-set-attr _el-button "_" "on click call failAsync() put 'should not reach' into #out")
(dom-set-attr _el-button "_" "on click then call failAsync() then put 'should not reach' into #out then")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-set-attr _el-out "id" "out")
@@ -6263,7 +6263,7 @@
(deftest "rejected promise triggers catch block"
(hs-cleanup!)
(let ((_el-button (dom-create-element "button")) (_el-out (dom-create-element "div")))
(dom-set-attr _el-button "_" "on click call failAsync() put 'unreachable' into #out catch e put e.message into #out")
(dom-set-attr _el-button "_" "on click then call failAsync() then put 'unreachable' into #out then catch e then put e.message into #out then")
(dom-append (dom-body) _el-button)
(hs-activate! _el-button)
(dom-set-attr _el-out "id" "out")
@@ -6778,7 +6778,7 @@
(let ((_el-box (dom-create-element "div")) (_el-template (dom-create-element "template")) (_el-test-where-comp (dom-create-element "test-where-comp")))
(dom-set-attr _el-box "id" "box")
(dom-append (dom-body) _el-box)
(dom-set-attr _el-template "_" "set :items to <span/> in #box where it matches .a on click put :items.length into me")
(dom-set-attr _el-template "_" "set :items to <span/> in #box where it matches .a then on click put :items.length into me")
(dom-set-attr _el-template "component" "test-where-comp")
(dom-append (dom-body) _el-template)
(hs-activate! _el-template)
@@ -7219,7 +7219,7 @@
(let ((_el-bar (dom-create-element "div")) (_el-div (dom-create-element "div")))
(dom-set-attr _el-bar "id" "bar")
(dom-append (dom-body) _el-bar)
(dom-set-attr _el-div "_" "on click add .foo to #bar then add .blah")
(dom-set-attr _el-div "_" "on click then add .foo to #bar then add .blah")
(dom-append (dom-body) _el-div)
(hs-activate! _el-div)
(dom-dispatch (dom-query "div:nth-of-type(2)") "click" nil)
@@ -7366,7 +7366,7 @@
(hs-cleanup!)
(let ((_el-d1 (dom-create-element "div")))
(dom-set-attr _el-d1 "id" "d1")
(dom-set-attr _el-d1 "_" "on click 1 set :x to 10 on click 2 set @out to :x")
(dom-set-attr _el-d1 "_" "on click 1 set :x to 10 then on click 2 set @out to :x")
(dom-append (dom-body) _el-d1)
(hs-activate! _el-d1)
(dom-dispatch (dom-query-by-id "d1") "click" nil)