From 2dc4b3e6d92e910a0a54bfa2f9dfe6c9db207741 Mon Sep 17 00:00:00 2001 From: Alys Brooks Date: Fri, 26 May 2023 15:52:50 -0500 Subject: [PATCH] Make the attribute id take priority over the tag. 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. --- src/lambdaisland/hiccup.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lambdaisland/hiccup.clj b/src/lambdaisland/hiccup.clj index 481dfc4..eac6f90 100644 --- a/src/lambdaisland/hiccup.clj +++ b/src/lambdaisland/hiccup.clj @@ -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]