@raywillig / @flyboarder i'm having a lot of trouble with hoplon/google-maps...
my objective is really to update hoplon/google-loader (on which hoplon/google-maps depends) so that we can always load the google maps JS API over https
i think pushing what's on hoplon/google-loader master to clojars as a new release is still a TODO item
i've tried the following two things:
• creating an adzerk/google-maps fork which includes the updated google-loader code directly in the repo
• adding :exclusions [hoplon/google-loader]
to my hoplon/google-maps dependency vector and pulling the updated source code directly into my project's repo
when i do either of those, i get this console error upon page load:
core.cljs:316 Uncaught Error: No protocol method IDeref.-deref defined for type object: [object Event]
at Object.cljs$core$missing_protocol [as missing_protocol] (core.cljs:316)
at Object.cljs$core$_deref [as _deref] (core.cljs:671)
at cljs$core$deref (core.cljs:1449)
at HTMLInputElement.<anonymous> (input.cljs:8)
input.cljs is from my project, which i'm aware is not particularly helpful. anyway, any help would be appreciated, this is quite frustratingwhat i'm really hoping for is a new release of hoplon/google-loader that i can pull in and have it magically work 😅 i feel like there might be something special about building that dep that i'm not doing
@dave that error message looks like @e
or similar is being used in an event handler
this is the offending code in my codebase, unchanged for > 2 years:
(defn- change-state
[state handler]
(let [handler (or handler (fn []))]
#(do (when state (reset! state @%))
(handler %))))
i guess the issue is what's being passed in there
it's very weird, though, because i didn't change anything about the code that calls that function
when i comment out calls to that function, that particular error goes away, but i'm also seeing this error:
core.cljs:717 Uncaught TypeError: elem.addEventListener is not a function
at core.cljs:717
at core.cljs:370
traced it to this line in my code:
(on! $e :focus #(when (and (cell? disabled) @disabled) (.datepicker $e "disable")))
which calls into here in hoplon.core...
(defmethod on! ::default
[elem event callback]
(when-dom elem #(.addEventListener elem (name event) callback)))
so i guess $e
ends up not being an elem in that case
in my code:
(with-let [e ((input/input :type "text") (dissoc attr :state :opts))]
(with-timeout 0
(let [$e (js/jQuery e)]
input/input
is currently this:
(defelem input [attr kids] (div) #_(field hoplon.core/input attr kids))
so i don't get it. it seems like that ought to return an element (an ordinary div)your code hasn’t changed, but hoplon has changed i think
in particular, something like @%
in your original code doesn’t work by default anymore
%
there is a jQuery event object, which in previous versions of hoplon cljs.core.IDeref was extended to, so that \@e would pull out the event’s value
at least… that’s my theory
Aha. That sounds like a good theory. I'll see if I can chase it down after lunch. Maybe we were unexpectedly using an older version of Hoplon before due to transitive dependencies
it's weird... hoplon/google-loader does actually have a dependency on an older hoplon version, 6.0.0-alpha10: https://github.com/hoplon/google-loader/blob/21aaeaf5857e83a89469daf19ed5818d77daf2aa/build.boot#L5
however, when i remove :exclusions [hoplon/google-loader]
from my hoplon/google-maps dependency vector and i do boot show -d
, i don't see hoplon 6.0.0-alpha10 in there anywhere
i wonder if maybe when the latest hoplon/google-maps was pushed to clojars, whoever did it commented out the hoplon dependency
that still doesn't explain the JS console error i'm running into, though...
i guess it doesn't matter. it sounds like at any rate, if we're using hoplon 7.1.0, then we need to fix the issue @alandipert mentioned above, about cljs.core.IDeref no longer being extended to jquery event objects
has anyone else here run into this?
if you scroll up to thurs. may 30th, someone else ran into it, in the context of making it work with gclosure
👓
whew, i fixed it
i'm not entirely sure why i have to do this now whereas i didn't before, but the fix was to require hoplon.jquery
somewhere in my project
i guess maybe that used to be required automatically (maybe by hoplon.core?) and somehow we ended up using an old version of hoplon before
the version of hoplon we thought we've been using this whole time is 7.1.0
but i suspect that maybe we ended up using an older version, unbeknownst to us, via transitive dependencies
oh yeah, requiring hoplon.jquery became necessary at some point
@dave @alandipert I ran into the issue of using @%
to extract value of an event in Closure.
We already have gclosure, why shouldn't Jquery be made optional?
it is optional, you now have to opt in
and if you don’t opt in via (require hoplon.jquery)
somewhere, you get dave’s error
Yes attribute providers are optional, so you can pick and choose your own library to handle implementation
We handle the default browser cases and leave you to include jquery or google closure on your own
This is well documented in the example code and the wiki