clojurescript 2025-02-03

This is wrong, isn’t it?

(let [{:keys [foo-bar foo_bar] :as m} {:foo_bar ""}]
  [foo-bar (:foo-bar m) foo_bar (:foo_bar m)])
;;=> ["" nil "" ""]

cljs.core/*clojurescript-version*
;;=> "1.11.132"

dashes in cljs are converted into underscores in js, I think this is known and was reported before

this is known yeah. I think there is an open issue for this

js strikes back

➕ 2

So then all the other strange cases I have found are just the same, “all bets are off”.

js doesn't have - in variable names, so they all get converted to _. so both end up as foo_bar and shadow each other. if you mix _ and - frequently you basically asking for trouble 😛

😅 1

@a13 more like an oversight in cljs itself

you think they should be converted to __DASH__ or something?

Can I trust (:foo-bar m) and (:foo_bar m)?

I mean, is the oversight in destructuring, or more generally?

its only symbols. keywords are fine. well not even symbols, binding names really

Not the answer I expected, but only shows how clueless I am. 😃 I take it as “you can trust the keyword functions”?

I can’t find the issue in the tracker. I’m probably not searching for the right terms.

> you think they should be converted to __DASH__ or something? It already happens in some contexts, but I don't know the impl of CLJS well enough to see what exactly is going on. The function in question is cljs.analyzer/gen-constant-id.

👍 2

Wow, this could cause a surprise in "working" code ported from clj to cljc... I would consider attaching a smiley if someone propounds a cogent suggestion for the linter to warn about it

I remember there was an open jira, but I couldn't find it. BTW: what if it pops up as a compiler warning?! At least, a #clj-kondo lint 👀

Hi guys, new here! Is there a package to change hiccup into str for clojurescript frontend that isn't dependent on reagant / rum react bindings?

The question is a bit ambiguous. Will that conversion run on ClojureScript or on Clojure?

On ClojureScript

(def app-element (gdom/getElement "app"))

(defn page []
  [:h1 {:class "title"} "Hello Guys"])

(defn render-app []
  (set! (.-innerHTML app-element) (html (page))))

(render-app)

These are great @p-himik - thank you so much!

👍 1