Skip to content

Commit

Permalink
Fix some issues with styles as js-value
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Aug 23, 2024
1 parent 8e205d5 commit 0016623
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/rumext/v2/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -415,25 +415,29 @@
expression. Mainly used by macros for create js data structures at
compile time."
[form]
(if (empty? form)
(list 'js* "{}")
(let [[keys vals] (compile-kv-to-js form)]
(-> (apply list 'js* (str "{" keys "}") vals)
(vary-meta assoc :tag 'object)))))
(if (map? form)
(if (empty? form)
(list 'js* "{}")
(let [[keys vals] (compile-kv-to-js form)]
(-> (apply list 'js* (str "{" keys "}") vals)
(vary-meta assoc :tag 'object))))
form))

(defn compile-vec-to-js
"Compile a statically known map data sturcture, non-recursivelly to js
expression. Mainly used by macros for create js data structures at
compile time."
[form]
(if (empty? form)
(list 'js* "[]")
(let [template (->> form
(map (constantly "~{}"))
(interpose ",")
(apply str))]
(-> (apply list 'js* (str "[" template "]") form)
(vary-meta assoc :tag 'object)))))
(if (vector? form)
(if (empty? form)
(list 'js* "[]")
(let [template (->> form
(map (constantly "~{}"))
(interpose ",")
(apply str))]
(-> (apply list 'js* (str "[" template "]") form)
(vary-meta assoc :tag 'object))))
form))

(defn compile-props-to-js
[props & {:keys [::transform-props-recursive
Expand Down

0 comments on commit 0016623

Please sign in to comment.