From 3d18750f03a50e87816cfa234f866cf4cc8f05e9 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Sat, 10 Jan 2026 15:26:52 +0200 Subject: Fix HTML rendering to handle nil values without removing sibling elements; add tests for nil handling in node hierarchy (#15) --- test/dompa/nodes_test.cljc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test/dompa') diff --git a/test/dompa/nodes_test.cljc b/test/dompa/nodes_test.cljc index b1c7b0f..da9b7db 100644 --- a/test/dompa/nodes_test.cljc +++ b/test/dompa/nodes_test.cljc @@ -130,6 +130,44 @@ ($ x)) ["l" "d"])])])))))) +(deftest nil-in-hierarchy-does-not-remove-siblings-test + (testing "nil in a fragment should not remove sibling elements" + (is (= "
one
two
" + (nodes/->html + [($ :<> + ($ :div "one") + ($ :div "two") + nil)])))) + + (testing "nil between siblings should not affect them" + (is (= "
one
two
" + (nodes/->html + [($ :<> + ($ :div "one") + nil + ($ :div "two"))])))) + + (testing "multiple nils should not affect siblings" + (is (= "
one
two
three
" + (nodes/->html + [($ :<> + nil + ($ :div "one") + nil + ($ :div "two") + nil + ($ :div "three") + nil)])))) + + (testing "nil inside nested element should not affect parent siblings" + (is (= "
hello
world
" + (nodes/->html + [($ :<> + ($ :div + ($ :span "hello") + nil) + ($ :div "world"))]))))) + (deftest traverse-test (let [traverser-fn (fn [node] (if (= :dompa/text (:node/name node)) -- cgit v1.2.3