This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-10
Channels
- # announcements (3)
- # asami (4)
- # babashka (21)
- # beginners (97)
- # calva (32)
- # cider (4)
- # clj-kondo (7)
- # cljdoc (1)
- # clojure (70)
- # clojure-europe (27)
- # clojure-nl (10)
- # clojure-norway (18)
- # clojure-uk (8)
- # clojure-ukraine (1)
- # clojurescript (5)
- # datalevin (7)
- # docker (1)
- # emacs (3)
- # fulcro (4)
- # girouette (4)
- # graalvm (2)
- # graphql (9)
- # gratitude (3)
- # honeysql (4)
- # hoplon (3)
- # hyperfiddle (7)
- # jobs (3)
- # kaocha (31)
- # lsp (23)
- # malli (7)
- # missionary (6)
- # nextjournal (9)
- # off-topic (6)
- # pathom (13)
- # polylith (13)
- # practicalli (3)
- # remote-jobs (3)
- # reveal (7)
- # schema (1)
- # sci (23)
- # shadow-cljs (31)
- # tools-deps (62)
- # xtdb (8)
I'm seeing some bizarre behavior with def regarding browser events in cljs. Try running a browser repl. (like the one at http://clojurescript.io) Run
(.addEventListener js/window
"paste"
(fn [event]
(def e event)
(js/console.log (.getData (.-clipboardData event) "text/plain"))))
Try pasting some text.
Now you should have your last 'paste' event bound to the var e
. And you will have seen your pasted text logged to the console.
If you eval e
in your repl, you do see a ClipboardEvent, however if you actually look into what is in that ClipboardEvent, it's essentially "blank".
You can check this with
(.getData (.-clipboardData e) "text/plain")
Anyone have any idea what's going on here? Does it regard some subtle difference in how def
works in cljs, or something about events?the https://w3c.github.io/clipboard-apis/#clipboard-event-api has this to say about clipboard events
> Access to the clipboard is performed using the standard DataTransfer
methods to mutate the items
on a ClipboardEvent
's clipboardData
attribute. One consequence of this is that these clipboard APIs can only access clipboard data in the context of a ClipboardEvent
handler.
it's just you're trying to access the data on a clipboard event outside of an event handler
thanks, good to know it's a consequence of the clipboard then. Thank you.