Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8cb81db

Browse files
committedApr 26, 2021
CLJS-3307: Allow extending IAssociative -contains-key? to native
1 parent 168b8a4 commit 8cb81db

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
 

‎src/main/cljs/cljs/core.cljs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,6 +2364,9 @@ reduces them without incurring seq initialization"
23642364
(implements? IAssociative coll)
23652365
(-contains-key? coll v)
23662366

2367+
(native-satisfies? IAssociative coll)
2368+
(-contains-key? coll v)
2369+
23672370
(identical? (get coll v lookup-sentinel) lookup-sentinel)
23682371
false
23692372

‎src/test/cljs/cljs/extend_to_native_test.cljs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,11 @@
144144

145145
(deftest test-protocol-with-slash
146146
(is (= "result" (/ ""))))
147+
148+
(deftest test-cljs-3307
149+
(extend-type object
150+
IAssociative
151+
(-contains-key? [_ k] (= k :valid)))
152+
153+
(is (contains? #js {} :valid))
154+
(is (not (contains? #js {} :invalid))))

0 commit comments

Comments
 (0)
Please sign in to comment.