HS: parser+compiler — toggle for-in lookahead, throttled/debounced modifiers (-2 skips)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s
parser.sx parse-toggle-cmd: when seeing 'toggle .foo for', peek the following two tokens. If they are '<ident> in', it is a for-in loop and toggle does NOT consume 'for' as a duration clause. Restores the trailing for-in to the command list. parser.sx parse-on (handler modifiers): recognize 'throttled at <ms>' and 'debounced at <ms>' as handler modifiers. Captured as :throttle / :debounce kwargs in the on-form parts list. compiler.sx emit-on: pre-extract :throttle / :debounce from parts via new _strip-throttle-debounce helper before scan-on, then wrap the built handler with (hs-throttle! handler ms) or (hs-debounce! handler ms). runtime.sx: hs-throttle! — closure with __hs-last-fire timestamp, fires immediately and drops events arriving within ms of the last fire. hs-debounce! — closure with __hs-timer, clears any pending timer and schedules a new setTimeout(handler, ms) so only the last burst event fires. Both formerly-architectural skips now pass: - "toggle does not consume a following for-in loop" - "throttled at <time> drops events within the window" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10036,8 +10036,10 @@
|
||||
(dom-set-attr _el-d "_" "on click throttled at 200ms then increment @n then put @n into me")
|
||||
(dom-append (dom-body) _el-d)
|
||||
(hs-activate! _el-d)
|
||||
(assert= (dom-text-content (dom-query-by-id "d")) "1")
|
||||
))
|
||||
(dom-dispatch _el-d "click" nil)
|
||||
(dom-dispatch _el-d "click" nil)
|
||||
(assert= (dom-text-content (dom-query-by-id "d")) "1"))
|
||||
)
|
||||
(deftest "uncaught exceptions trigger 'exception' event"
|
||||
(hs-cleanup!)
|
||||
(let ((_el-button (dom-create-element "button")))
|
||||
@@ -13867,7 +13869,19 @@ end")
|
||||
(assert= (dom-text-content _out) "2"))
|
||||
)
|
||||
(deftest "toggle does not consume a following for-in loop"
|
||||
(error "SKIP (untranslated): toggle does not consume a following for-in loop"))
|
||||
(hs-cleanup!)
|
||||
(let ((_out (dom-create-element "div")) (_btn (dom-create-element "div")))
|
||||
(dom-set-attr _out "id" "out")
|
||||
(dom-set-attr _btn "id" "btn")
|
||||
(dom-set-attr _btn "_" "on click toggle .foo for x in [1, 2, 3] put x into #out end")
|
||||
(dom-append (dom-body) _out)
|
||||
(dom-append (dom-body) _btn)
|
||||
(hs-activate! _btn)
|
||||
(assert (not (dom-has-class? _btn "foo")))
|
||||
(dom-dispatch _btn "click" nil)
|
||||
(assert (dom-has-class? _btn "foo"))
|
||||
(assert= (dom-text-content _out) "3"))
|
||||
)
|
||||
)
|
||||
|
||||
;; ── transition (17 tests) ──
|
||||
|
||||
Reference in New Issue
Block a user