summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsko Nõmm <asko@repl.ee>2025-10-19 17:57:04 +0300
committerGitHub <noreply@github.com>2025-10-19 17:57:04 +0300
commit9276f08031242c13ee25c8f89c22e4f65cff004b (patch)
tree233d6208d16ffb3b0d2f1ad76639f673382f233b
parent8d3d1ab9d1c1b0c1da0f5f30f1e98dc4a3bd06a5 (diff)
parentc3c62d780457a2fa1de1ab80ba66fdd1c82d6520 (diff)
Merge pull request #2 from askonomm/1-self-closing-tags-break-in-dompacoordinateshtml-attrs-html
#1: Fixes an issue where self-closing elements would break the attrs …
-rw-r--r--src/dompa/coordinates.cljc2
-rw-r--r--test/dompa/coordinates_test.cljc8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/dompa/coordinates.cljc b/src/dompa/coordinates.cljc
index bba8b5c..ebe9b65 100644
--- a/src/dompa/coordinates.cljc
+++ b/src/dompa/coordinates.cljc
@@ -270,7 +270,7 @@
(partition-by #(= % \space))
(drop 1)
flatten
- (reduce str)
+ (apply str)
str/trim))
(defn- html-str->node-attrs
diff --git a/test/dompa/coordinates_test.cljc b/test/dompa/coordinates_test.cljc
index 85a4518..79248e3 100644
--- a/test/dompa/coordinates_test.cljc
+++ b/test/dompa/coordinates_test.cljc
@@ -107,6 +107,14 @@
coordinates/compose
coordinates/unify
coordinates/->nodes))))
+
+ (testing "Create nodes from self-closing tags"
+ (is (= [{:node/name :hr
+ :node/attrs {}}]
+ (-> "<hr />"
+ coordinates/compose
+ coordinates/unify
+ coordinates/->nodes))))
(testing "Create nodes with attributes"
(is (= [{:node/name :div