Fork me on GitHub
#squint
<
2023-12-05
>
guliy04:12:25

I updated to squint 0.4.72 and it looks like conditional rendering is broken (defn App [] (let [picked-emoji true] #jsx [View {} (if picked-emoji #jsx [Text "Picker"] #jsx [Text "Not picked"])])) Compiling to var App = (function () { let picked_emoji1 = true; return (squint_core.truth_(picked_emoji1)) ? (Picker) : (Not picked) }); (squint_core.truth_(picked_emoji1)) ? (Picker) : (Not picked) lost {} around (

1
guliy04:12:10

in 0.4.68 still works

guliy05:12:09

so, i found out than it was broken exactly in 0.4.72

guliy05:12:24

in previous versions it works as expected

borkdude06:12:43

Can you create an issue? I will fix in an hour or two

👍 1
borkdude10:12:31

@U5B5BAVB6 should be fixed in .73

💪 2
borkdude18:12:21

I wonder if there is interest in a construct in #C03U8L2NXNC which lets you "compile" literal HTML, like so:

😮 4
👍 2
👏 1
1
1
borkdude18:12:59

It is compiled straight to a templated string so it just works ™️ and you can render it into the dom with innerHTML and friends

Cora (she/her)18:12:08

I would've loved to have had that with the playground boilerplate

👆 1
zane19:12:00

Yes, definitely.

Cora (she/her)20:12:47

would be kind of nice to not have to do :onclick "bar()" and instead be able to do :onclick bar -- and have bar receive the event object when it's triggered

borkdude21:12:14

with "bar(this)" you only get the element and not the event right?

borkdude21:12:30

another idea to configure the tag, e.g. for lit/html:

(defn my-tag [& args]
  args)

(def x 1)

#html ^my-tag [:div "Hello" x] ;;=> [ [ '<div>Hello', '</div>' ], 1 ]

Cora (she/her)21:12:05

I actually hadn't really handled receiving events and such in inline event handlers https://stackoverflow.com/a/16404397

Cora (she/her)21:12:16

I knew there was a way

Cora (she/her)21:12:19

but it seems messy

borkdude21:12:32

oh window.event, gosh

Cora (she/her)21:12:16

yeah, the other answers aren't great either

Cora (she/her)21:12:33

<p onclick="doSomething(a,b,event,c,d)">

Cora (she/her)21:12:03

it scans for "event" and passes it in that position 😬

Cora (she/her)21:12:40

so yeah, anything we can do to make this not gross would be amazing

borkdude21:12:21

Probably just writing addEventListener manually would be the least surprising. The #html isn't any magic, just hiccup rendering basically

1
borkdude11:12:06

Interaction of the #html construct with lit-html

borkdude21:12:30

another idea to configure the tag, e.g. for lit/html:

(defn my-tag [& args]
  args)

(def x 1)

#html ^my-tag [:div "Hello" x] ;;=> [ [ '<div>Hello', '</div>' ], 1 ]

borkdude21:12:18

and we could have normal #str ^lit/html ["" x ""] to make template string more generalized