Fork me on GitHub
#hoplon
<
2017-06-29
>
thedavidmeister05:06:38

ugh, i think i need a hand with google closure events

thedavidmeister05:06:47

in hoplon i see stuff like this

thedavidmeister05:06:50

(defmethod do! :select
  [elem _ _]
  (events/dispatchEvent elem goog.events.EventType.SELECT))

thedavidmeister05:06:54

i'm trying to emulate that

thedavidmeister05:06:06

i wrote a function like this

thedavidmeister05:06:08

(defn input-val!
 "Sets the val of el to the given v, but also triggers input, which is often necessary for tests."
 [el v]
 (val! el v)
 (goog.events/dispatchEvent el goog.events.EventType.INPUT))

thedavidmeister05:06:30

which is just a port of a jquery based function i had before

thedavidmeister05:06:40

i wrote a simple test

thedavidmeister05:06:43

(deftest ??input-val!
 (let [c (j/cell nil)
       el (h/input :input #(reset! c @%))]
  (input-val! el "foo")
  (is (= "foo" @c))))

thedavidmeister05:06:24

the result i'm seeing is this

thedavidmeister05:06:24

Assertion failed: Can not use goog.events.dispatchEvent with non-goog.events.Listenable instance.

thedavidmeister05:06:31

so, what is hoplon doing that i'm not doing?

thedavidmeister06:06:05

this doesn't work

thedavidmeister06:06:07

(deftest ??hoplon-select
 (h/input :select true))

flyboarder06:06:17

@thedavidmeister I think we can resolve much of this, I’m not sure where the on! multi-method went for goog

thedavidmeister06:06:49

i think there's two things going on

thedavidmeister06:06:06

1. maybe we can improve hoplon.goog

thedavidmeister06:06:27

2. i feel like i'm shaving yaks when what i really want is for SVG to not break in hoplon.jquery

flyboarder06:06:02

@thedavidmeister yeah, we can fix both those things hahaha

flyboarder06:06:34

so for svg support, we should replace the internal :svg/* implementation

flyboarder06:06:46

it shouldnt work the same as the regular attributes

thedavidmeister06:06:03

yeah, it should just do the same thing as -set-attributes! in hoplon.core i think

flyboarder06:06:15

hoplon core is what it does currently

thedavidmeister06:06:31

well, the old one

thedavidmeister06:06:55

it just needs to be (.setAttribute elem k v)

thedavidmeister06:06:02

which i think it was in core at some point

thedavidmeister06:06:25

but i think it has changed to .attr from jquery since jquery/goog split

flyboarder06:06:27

yeah still is, we can just remove the jquery one and it will use the vanillajs version

thedavidmeister07:06:48

i can put a pr up for that

flyboarder07:06:22

yeah since svg is a known broken thing with jquery it really shouldnt have a method for that

flyboarder07:06:46

my bad, probably an artifact from when I split jquery out from core

thedavidmeister07:06:47

the flipside is that there should be many more tests running to catch stuff like this

thedavidmeister07:06:38

@flyboarder ^^ tests passing on this

jjttjj18:06:15

I vaguely remember a longish discussion from awhile back on being able to access attributes as keywords like that. Did I dream that? Might have been on discourse or an issue but I haven't been able to find it

flyboarder21:06:36

@jjttjj It would simply need replacing of the current IFn with a protocol that does type dispatch, or we can localize the type check to a cond

jjttjj21:06:04

@flyboarder cool yeah I have no opinion on it one way or the other, seems cool to me, just had some deja vu that it was discussed before (and I don't remember the outcome of the discussion)

flyboarder21:06:22

yeah I think it’s worth a PR 😛

flyboarder21:06:53

do I have time for it tho

jjttjj21:06:54

btw awesome work on all the spec stuff, I'm just getting up to speed with clojure spec now finally and loving it

jjttjj21:06:18

It's nice seeing it get into hoplon

flyboarder21:06:29

no prob :thumbsup: it was worth it, I basically took my app and wrote specs until my existing app passed

flyboarder21:06:13

and now there is some ground work for whatever spec final ends up being

jjttjj21:06:30

yeah that's great

flyboarder21:06:10

but I think the core file is getting long, probably due for a cleanup