From b633a02d403e78732b8a7fb06569f70ce4af604d Mon Sep 17 00:00:00 2001 From: Karl Hardenstine Date: Fri, 13 Jul 2018 11:26:50 -0400 Subject: [PATCH 1/3] Comparing PartialFn to nil is false/unexceptional #385 --- src/reagent/impl/util.cljs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/reagent/impl/util.cljs b/src/reagent/impl/util.cljs index 56b0df6..8e365ce 100644 --- a/src/reagent/impl/util.cljs +++ b/src/reagent/impl/util.cljs @@ -114,7 +114,9 @@ (apply pfn a b c d e f g h i j k l m n o p q r s t rest)) IEquiv (-equiv [_ other] - (and (= f (.-f other)) (= args (.-args other)))) + (and (instance? PartialFn other) + (= f (.-f other)) + (= args (.-args other)))) IHash (-hash [_] (hash [f args]))) From a1953f27333bb23ffcf5132d34c71a4e180fffba Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Mon, 31 Dec 2018 12:55:11 +0200 Subject: [PATCH 2/3] Add test for PartialFn equiv --- test/reagent/impl/util_test.cljs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/reagent/impl/util_test.cljs b/test/reagent/impl/util_test.cljs index 90cd785..311d4a3 100644 --- a/test/reagent/impl/util_test.cljs +++ b/test/reagent/impl/util_test.cljs @@ -69,3 +69,10 @@ {:class ["baz" "quux"]}) (util/merge-props nil {:class ["foo" "bar" "baz" "quux"]}) (util/merge-props {:class ["foo" "bar" "baz" "quux"]}))))) + +(deftest partial-fn-test + (is (= (util/make-partial-fn println ["a"]) + (util/make-partial-fn println ["a"]))) + + (is (not (= (util/make-partial-fn println ["a"]) + nil)))) From 06482e9d3e6a8a4a8b2a0c22e8f2cf150dfcaa03 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Mon, 31 Dec 2018 12:56:18 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 897ba01..a9afd09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ensure `:class` is merged correctly when it is defined as collection. ([#412](https://github.com/reagent-project/reagent/issues/412)) - Add `reagent.core/class-names` utility functions which can be used to normalize and combine `:class` values (similar to `classnames` JS library) +- Fix comparing Reagent `PartialFn` to `nil` ([#385](https://github.com/reagent-project/reagent/issues/385)) ## 0.8.1 (2018-05-15)