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"
It wasn’t tracked. Now it is: https://clojure.atlassian.net/browse/CLJS-3426
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
til
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 😛
@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.
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 👀
I added it https://ask.clojure.org/index.php/14370/clojurescript-destructuring-differing-underscore-doesnt to give it some visibility for web searches and LLMs.
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
• https://github.com/teropa/hiccups • https://github.com/jeluard/hipo • https://github.com/borkdude/html • https://github.com/ibdknox/crate If you don't really need an HTML string but rather HTML rendering, then maybe https://github.com/cjohansen/replicant. All were found with https://phronmophobic.github.io/dewey/search.html.
(def app-element (gdom/getElement "app"))
(defn page []
[:h1 {:class "title"} "Hello Guys"])
(defn render-app []
(set! (.-innerHTML app-element) (html (page))))
(render-app)