diff --git a/lib/hyperscript/runtime.sx b/lib/hyperscript/runtime.sx index 6f8ac0ae..3395b461 100644 --- a/lib/hyperscript/runtime.sx +++ b/lib/hyperscript/runtime.sx @@ -377,19 +377,21 @@ hs-for-each (fn (fn-body collection) - (define - do-loop - (fn - (items) - (when - (not (empty? items)) - (let - ((signal (guard (e (true (str e))) (do (fn-body (first items)) nil)))) - (cond - ((= signal "hs-break") nil) - ((= signal "hs-continue") (do-loop (rest items))) - (true (do-loop (rest items)))))))) - (when (list? collection) (do-loop collection)))) + (let + ((items (cond ((list? collection) collection) ((dict? collection) (keys collection)) ((nil? collection) (list)) (true (list))))) + (define + do-loop + (fn + (remaining) + (when + (not (empty? remaining)) + (let + ((signal (guard (e (true (str e))) (do (fn-body (first remaining)) nil)))) + (cond + ((= signal "hs-break") nil) + ((= signal "hs-continue") (do-loop (rest remaining))) + (true (do-loop (rest remaining)))))))) + (do-loop items)))) (define hs-fetch