diff --git a/lib/hyperscript/compiler.sx b/lib/hyperscript/compiler.sx index 41918e13..fb0171ad 100644 --- a/lib/hyperscript/compiler.sx +++ b/lib/hyperscript/compiler.sx @@ -264,8 +264,17 @@ name (hs-to-sx (nth ast 2)))) ((= (len ast) 3) - (list (quote dom-dispatch) (hs-to-sx (nth ast 2)) name nil)) - (true (list (quote dom-dispatch) (quote me) name nil)))))) + (list + (quote dom-dispatch) + (hs-to-sx (nth ast 2)) + name + (list (quote dict) "sender" (quote me)))) + (true + (list + (quote dom-dispatch) + (quote me) + name + (list (quote dict) "sender" (quote me)))))))) (define emit-repeat (fn @@ -650,11 +659,15 @@ ((number? ast) ast) ((string? ast) ast) ((boolean? ast) ast) + ((and (symbol? ast) (= (str ast) "sender")) + (list (quote hs-sender) (quote event))) ((not (list? ast)) ast) (true (let ((head (first ast))) (cond + ((= head (quote sender)) + (list (quote hs-sender) (quote event))) ((= head (quote null-literal)) nil) ((= head (quote not)) (list (quote not) (hs-to-sx (nth ast 1)))) diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index 9723d9a3..92556fd9 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -151,6 +151,8 @@ (do (adv!) (parse-the-expr))) ((and (= typ "keyword") (= val "me")) (do (adv!) (list (quote me)))) + ((and (= typ "keyword") (= val "sender")) + (do (adv!) (list (quote sender)))) ((and (= typ "keyword") (= val "I")) (do (adv!) (list (quote me)))) ((and (= typ "keyword") (= val "it")) diff --git a/lib/hyperscript/runtime.sx b/lib/hyperscript/runtime.sx index 4618424d..2576b3f9 100644 --- a/lib/hyperscript/runtime.sx +++ b/lib/hyperscript/runtime.sx @@ -687,6 +687,14 @@ (dom-insert-adjacent-html target "beforeend" (str value))) (true nil))))) ;; Property-based is — check obj.key truthiness +(define + hs-sender + (fn + (event) + (let + ((detail (host-get event "detail"))) + (if detail (host-get detail "sender") nil)))) +;; Array slicing (inclusive both ends) (define hs-host-to-sx (fn @@ -740,7 +748,7 @@ (dict-set! out k (hs-host-to-sx (host-get v k)))) (host-call (host-global "Object") "keys" v)) out))))))))))) -;; Array slicing (inclusive both ends) +;; Collection: sorted by (define hs-fetch (fn @@ -750,7 +758,7 @@ (let ((raw (perform (list "io-fetch" url fmt)))) (cond ((= fmt "json") (hs-host-to-sx raw)) (true raw)))))) -;; Collection: sorted by +;; Collection: sorted by descending (define hs-json-escape (fn @@ -781,7 +789,7 @@ (walk) out) "\""))) -;; Collection: sorted by descending +;; Collection: split by (define hs-json-stringify (fn @@ -815,7 +823,7 @@ ks))) "}"))) (true (hs-json-escape (str v)))))) -;; Collection: split by +;; Collection: joined by (define hs-coerce (fn @@ -929,7 +937,7 @@ (map (fn (k) (list k (get value k))) (keys value)) value)) (true value)))) -;; Collection: joined by + (define hs-gather-form-nodes (fn diff --git a/shared/static/wasm/sx/hs-compiler.sx b/shared/static/wasm/sx/hs-compiler.sx index 41918e13..fb0171ad 100644 --- a/shared/static/wasm/sx/hs-compiler.sx +++ b/shared/static/wasm/sx/hs-compiler.sx @@ -264,8 +264,17 @@ name (hs-to-sx (nth ast 2)))) ((= (len ast) 3) - (list (quote dom-dispatch) (hs-to-sx (nth ast 2)) name nil)) - (true (list (quote dom-dispatch) (quote me) name nil)))))) + (list + (quote dom-dispatch) + (hs-to-sx (nth ast 2)) + name + (list (quote dict) "sender" (quote me)))) + (true + (list + (quote dom-dispatch) + (quote me) + name + (list (quote dict) "sender" (quote me)))))))) (define emit-repeat (fn @@ -650,11 +659,15 @@ ((number? ast) ast) ((string? ast) ast) ((boolean? ast) ast) + ((and (symbol? ast) (= (str ast) "sender")) + (list (quote hs-sender) (quote event))) ((not (list? ast)) ast) (true (let ((head (first ast))) (cond + ((= head (quote sender)) + (list (quote hs-sender) (quote event))) ((= head (quote null-literal)) nil) ((= head (quote not)) (list (quote not) (hs-to-sx (nth ast 1)))) diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index 9723d9a3..92556fd9 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -151,6 +151,8 @@ (do (adv!) (parse-the-expr))) ((and (= typ "keyword") (= val "me")) (do (adv!) (list (quote me)))) + ((and (= typ "keyword") (= val "sender")) + (do (adv!) (list (quote sender)))) ((and (= typ "keyword") (= val "I")) (do (adv!) (list (quote me)))) ((and (= typ "keyword") (= val "it")) diff --git a/shared/static/wasm/sx/hs-runtime.sx b/shared/static/wasm/sx/hs-runtime.sx index 4618424d..2576b3f9 100644 --- a/shared/static/wasm/sx/hs-runtime.sx +++ b/shared/static/wasm/sx/hs-runtime.sx @@ -687,6 +687,14 @@ (dom-insert-adjacent-html target "beforeend" (str value))) (true nil))))) ;; Property-based is — check obj.key truthiness +(define + hs-sender + (fn + (event) + (let + ((detail (host-get event "detail"))) + (if detail (host-get detail "sender") nil)))) +;; Array slicing (inclusive both ends) (define hs-host-to-sx (fn @@ -740,7 +748,7 @@ (dict-set! out k (hs-host-to-sx (host-get v k)))) (host-call (host-global "Object") "keys" v)) out))))))))))) -;; Array slicing (inclusive both ends) +;; Collection: sorted by (define hs-fetch (fn @@ -750,7 +758,7 @@ (let ((raw (perform (list "io-fetch" url fmt)))) (cond ((= fmt "json") (hs-host-to-sx raw)) (true raw)))))) -;; Collection: sorted by +;; Collection: sorted by descending (define hs-json-escape (fn @@ -781,7 +789,7 @@ (walk) out) "\""))) -;; Collection: sorted by descending +;; Collection: split by (define hs-json-stringify (fn @@ -815,7 +823,7 @@ ks))) "}"))) (true (hs-json-escape (str v)))))) -;; Collection: split by +;; Collection: joined by (define hs-coerce (fn @@ -929,7 +937,7 @@ (map (fn (k) (list k (get value k))) (keys value)) value)) (true value)))) -;; Collection: joined by + (define hs-gather-form-nodes (fn