From bd5bbbda8146debb75ead440c9993161f752e764 Mon Sep 17 00:00:00 2001 From: itoooo <13117917+itoooo@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:44:16 +0900 Subject: [PATCH] fix: to prevent errors occuring when merging non-map value --- src/cljc/proton/core.cljc | 2 +- test/proton/core_test.cljc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cljc/proton/core.cljc b/src/cljc/proton/core.cljc index 916de66..8db146a 100644 --- a/src/cljc/proton/core.cljc +++ b/src/cljc/proton/core.cljc @@ -198,7 +198,7 @@ "Recursively merges maps." [& maps] (letfn [(m [& xs] - (if (some #(and (map? %) (not (record? %))) xs) + (if (every? #(and (map? %) (not (record? %))) xs) (apply merge-with m xs) (last xs)))] (reduce m maps))) diff --git a/test/proton/core_test.cljc b/test/proton/core_test.cljc index 351bf4f..de019a2 100644 --- a/test/proton/core_test.cljc +++ b/test/proton/core_test.cljc @@ -161,4 +161,6 @@ (is (= (core/deep-merge {:foo {:bar 1}} {:foo {:baz 2}}) {:foo {:bar 1 :baz 2}})) (is (= (core/deep-merge {:foo {:bar 1}} {:baz 2}) - {:foo {:bar 1} :baz 2}))) + {:foo {:bar 1} :baz 2})) + (is (= (core/deep-merge {:foo 1} {:foo {:baz 2}}) + {:foo {:baz 2}})))