评论者:kurtharriger
以上也表明,也许可以在nil上扩展IEncodeClojure?
a
不是nil
,但它的类型是...那么,也许在nil上扩展协议可以这样工作?
但不起作用...也许这是satisfies?
的一个bug?
`
cljs.user=> (def a (.create js/Object nil))
'cljs.user/a
cljs.user=> (aset a "test" 1)
1
cljs.user=> (extend-protocol IEncodeClojure)
nil
(-js->clj (link: x opts)
(let (link: {:keys [keywordize-keys)} opts
keyfn (if keywordize-keys keyword str)]
(into {} (for (link: k (js-keys x))
(link: (keyfn k) (js->clj (unchecked-get x k)) opts))))))
nil
cljs.user=> (js->clj a)
object(link: Object)
cljs.user=> (js-keys IEncodeClojure)
js (link: "null")
cljs.user=> (satisfies? IEncodeClojure a)
false
cljs.user=> (type a)
nil
`