Skip to content

Commit

Permalink
Make the attribute id take priority over the tag.
Browse files Browse the repository at this point in the history
This matches the behavior of Reagent and the original Hiccup.

For example, in `[:div#foo {:id "bar"}]`, the id would be bar and not
foo.
  • Loading branch information
Alys Brooks committed May 26, 2023
1 parent 95840a7 commit 2dc4b3e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lambdaisland/hiccup.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
(into {} (filter val m))
{})
:content (enlive/flatmap #(nodify % opts) (if (attr-map? m) ms more))}
node (if id (assoc-in node [:attrs :id] id) node)
node (if (and id (not (contains? (:attrs node) :id)))
(assoc-in node [:attrs :id] id) node)
node (if (seq classes)
(update-in node
[:attrs :class]
Expand Down

0 comments on commit 2dc4b3e

Please sign in to comment.