Skip to content

Commit

Permalink
Fix #19: add support for keyword spread operator
Browse files Browse the repository at this point in the history
  • Loading branch information
lilactown committed Mar 3, 2020
1 parent cbe31a0 commit de145d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dev/workshop/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
(let [div "div"
props {:style {:color "blue"}}
children '("foo" "bar")]
($ div {& props} children "baz")))
(<> "&" ($ div {& props} children "baz")
":&" ($ div {:& props} children "baz"))))

(dc/defcard dynamic
($ dynamic-test))
Expand Down
8 changes: 5 additions & 3 deletions src/helix/impl/props.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@


(defn -native-props
([m] #?(:clj (if-let [spread-sym (get m '&)]
`(merge-obj ~(-native-props (dissoc m '&) (primitive-obj))
(-native-props ~spread-sym))
([m] #?(:clj (if-let [spread-sym (cond
(contains? m '&) '&
(contains? m :&) :&)]
`(merge-obj ~(-native-props (dissoc m spread-sym) (primitive-obj))
(-native-props ~(get m spread-sym)))
(-native-props m (primitive-obj)))
:cljs (-native-props m (primitive-obj))))
([m o]
Expand Down

0 comments on commit de145d9

Please sign in to comment.