mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 19:28:12 +00:00
🐛 Fix spurious argument to dissoc in patch-object
The patch-object function was calling (dissoc object key value) when handling nil values. Since dissoc treats each argument after the map as a key to remove, this was also removing nil as a key from the map. The correct call is (dissoc object key).
This commit is contained in:
parent
6c90ba1582
commit
a2e6abcb72
@ -377,7 +377,7 @@
|
||||
(assoc object key nil)
|
||||
|
||||
(nil? value)
|
||||
(dissoc object key value)
|
||||
(dissoc object key)
|
||||
|
||||
:else
|
||||
(assoc object key value)))
|
||||
|
||||
@ -445,6 +445,8 @@
|
||||
(t/is (= {:a {:x 10 :y 2}} (d/patch-object {:a {:x 1 :y 2}} {:a {:x 10}})))
|
||||
;; nested nil removes nested key
|
||||
(t/is (= {:a {:y 2}} (d/patch-object {:a {:x 1 :y 2}} {:a {:x nil}})))
|
||||
;; nil value removes only the specified key, not other keys
|
||||
(t/is (= {nil 0 :b 2} (d/patch-object {nil 0 :a 1 :b 2} {:a nil})))
|
||||
;; transducer arity (1-arg returns a fn)
|
||||
(let [f (d/patch-object {:a 99})]
|
||||
(t/is (= {:a 99 :b 2} (f {:a 1 :b 2})))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user