Fork me on GitHub
#clojurescript
<
2016-08-14
>
flyboarder00:08:01

Can someone explain why (aset some-js-obj “style” “background-image” “value”) doesnt work?

flyboarder00:08:32

how can I correctly set a style in a way that will work with advanced compilation

flyboarder00:08:47

using vanilla js

timothypratley04:08:18

@flyboarder: (aset js/document.body "style" "background-image" "url()") worked for me... maybe some-js-obj isn't a dom element?

flyboarder05:08:29

@timothypratley: it works with the url portion in the string, I cannot just pass the string like you can in a css file

flyboarder05:08:05

I guess this makes sense

risto12:08:02

is there a clojurescript macro for json objects?

risto12:08:39

I need to pass a lot of settings objects for a JS library I'm using, but I don't want to convert using clj->js all the time

risto12:08:54

something like (blessed.screen (clj->js {:smartCSR true}))

risto12:08:43

I'm looking for something like a reader, like: (blessed.screen ->{:smartCSR true})

selfsame13:08:47

fp.flow=> (try (js/throw "bad") (catch js/Error e 6))
6
fp.flow=> (try (throw "bad") (catch js/Error e 6))
"bad"
No stacktrace available.
^ is this normal? (cljs 1.8.51)

dnolen13:08:07

@selfsame: yes “bad” isn’t an instance of js/Error

dnolen13:08:29

if you want to catch random stuff you need :default instead of js/Error

anmonteiro13:08:32

@selfsame: FWIW this works:

cljs.user=> (try (throw "bad") (catch :default e 6))
6

selfsame13:08:16

did not know about :default, thanks!

mfikes13:08:21

Perhaps one day Clojure will also support :default, enhancing portability: http://dev.clojure.org/jira/browse/CLJ-1293

mfikes14:08:22

For Cursive users: I’ve written an enhancement request to support the new clojure namespace aliasing feature. (https://github.com/cursive-ide/cursive/issues/1491)

risto14:08:04

do tagged literals work in clojurescript?

anmonteiro14:08:41

@risto: depends on what you mean by “work"

anmonteiro14:08:53

queue, inst, uuid and js are supported

anmonteiro14:08:08

but you can’t currently add new ones like in Clojure

risto14:08:01

yeah that's what I want to do

risto14:08:35

I'm just looking for some shorthand way of writing JSON objects without having to apply a separate expression with clj->js

risto14:08:18

something like (blessed.screen #clj->js {:foo "bar"}) rather than (blessed.screen (clj->js {:foo "bar"}))

risto14:08:49

it's not a big deal but just wondering if there's readers for that sort of thing. Or even nicer would be: (blessed.screen ->{:foo "bar"})

risto14:08:13

and <-someJson

anmonteiro14:08:37

@risto: so #js {:foo “bar”} works

anmonteiro14:08:27

also note that #js doesn’t nest, so you’ll want #js {:foo #js {:bar “baz"}} when nesting other js objects

risto17:08:22

@anmonteiro: Oh nice! thanks this is awesome

kbp20:08:09

I am playing with om next. I scraped some data with python and used edn_format to create a edn file with that data. What is the way to import that data into my app since I have it saved in "resources/data.edn"?

flyboarder21:08:29

@kbp: slurp a java.io.file

kbp21:08:52

thanks, i will look in to it. thanks again

flyboarder21:08:05

(slurp ( “resources/data.edn"))

kbp21:08:15

oh cool. peace to you

xcthulhu23:08:34

Okay, I know this is probably the last thing on everyone's mind, but is there a way of tightening the security for react in a ClojureScript app?

xcthulhu23:08:51

One attack vector is to modify React (in particular when it is making a form DOM element) to send data to the attacker. This sort of injection could be done, for instance, by a compromised ad server.

xcthulhu23:08:50

I mean in general this is a problem for everything on cljsjs

cfleming23:08:02

@mfikes: Thanks! I’m hoping to get that in the next build.

mfikes23:08:14

@cfleming: nice. Feel free to ping me if you end up with questions regarding any subtleties of its behavior :)