clojurescript 2025-02-24

Interesting. identical? works fine, but = fails 😄

(->> (js/document.getElementsByTagName "iframe")
     (some (fn [iframe]
             (when (= (.-contentWindow iframe)
                      (.-source js-event))
               iframe))))
I asssume that this breaks some things?
(core/defmacro coercive-= [x y]
  (bool-expr (core/list 'js* "(~{} == ~{})" x y)))

No, it's because = tries to call the -equiv function defined on the IEquiv protocol.

note that you can't just directly transfer objects between context, e.g. iframe and main document. this will never work for CLJS datastructures and they need to be serialized back and forth

Interesting. But the === operator works.

But it makes sense that it works this way.

JS uses a very weird sharing scheme that gives you basically a proxy to the original object which is meant for JSON like data and limited to it

What do you mean by it being meant for JSON?

not JSON. JSON like data. objects, numbers, strings, etc. not class instances

it can do a bit more, but it can't be extended

I can't remember actual details for iframes. been too long since I looked at the spec

I should look into that as well, it sounds interesting 😄

iframe works a bit differently IIRC, but same idea. limited set of supported types that can be copied transparently