Fork me on GitHub
#hoplon
<
2019-06-07
>
dave15:06:15

@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 frustrating

dave15:06:49

what 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

alandipert15:06:39

@dave that error message looks like @e or similar is being used in an event handler

dave16:06:22

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 %))))

dave16:06:05

i guess the issue is what's being passed in there

dave16:06:34

it's very weird, though, because i didn't change anything about the code that calls that function

dave16:06:33

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

dave16:06:55

traced it to this line in my code:

(on! $e :focus #(when (and (cell? disabled) @disabled) (.datepicker $e "disable")))

dave16:06:05

which calls into here in hoplon.core...

(defmethod on! ::default
  [elem event callback]
  (when-dom elem #(.addEventListener elem (name event) callback)))

dave16:06:34

so i guess $e ends up not being an elem in that case

dave16:06:14

in my code:

(with-let [e ((input/input :type "text") (dissoc attr :state :opts))]
      (with-timeout 0
        (let [$e (js/jQuery e)]

dave16:06:38

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)

alandipert16:06:33

your code hasn’t changed, but hoplon has changed i think

alandipert16:06:49

in particular, something like @% in your original code doesn’t work by default anymore

alandipert16:06:23

% 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

alandipert16:06:51

at least… that’s my theory

dave16:06:04

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

dave17:06:22

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

dave17:06:14

i wonder if maybe when the latest hoplon/google-maps was pushed to clojars, whoever did it commented out the hoplon dependency

dave17:06:38

that still doesn't explain the JS console error i'm running into, though...

dave17:06:25

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

dave17:06:45

has anyone else here run into this?

alandipert17:06:29

if you scroll up to thurs. may 30th, someone else ran into it, in the context of making it work with gclosure

dave18:06:10

whew, i fixed it

dave18:06:37

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

dave18:06:55

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

dave18:06:14

the version of hoplon we thought we've been using this whole time is 7.1.0

dave18:06:35

but i suspect that maybe we ended up using an older version, unbeknownst to us, via transitive dependencies

alandipert19:06:45

oh yeah, requiring hoplon.jquery became necessary at some point

Ahmed Hassan21:06:56

@dave @alandipert I ran into the issue of using @% to extract value of an event in Closure.

Ahmed Hassan21:06:44

We already have gclosure, why shouldn't Jquery be made optional?

alandipert21:06:35

it is optional, you now have to opt in

alandipert21:06:02

and if you don’t opt in via (require hoplon.jquery) somewhere, you get dave’s error

flyboarder21:06:56

Yes attribute providers are optional, so you can pick and choose your own library to handle implementation

flyboarder21:06:24

We handle the default browser cases and leave you to include jquery or google closure on your own

flyboarder21:06:06

This is well documented in the example code and the wiki