Clojurians
#hoplon
<
2016-03-21
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

leontalbot01:03:08

I found a solution. I must wrap my form into (form :id "form" ...), and when I send my form data, I also call this fn :

(defn reset-form [id]
  ;;For clearing fields when reloading form page in IE
  (-> js/document (.getElementById id) .reset))
`

leontalbot02:03:49

Have a great night @micha

thedavidmeister05:03:04

has anyone seen this "#object[String #;9]” when dereferencing an event?

thedavidmeister05:03:23

like :input #(prn @%) on a text input

thedavidmeister05:03:15

I expect to see ”#;9” but it’s wrapped in this String object thing in prn

levitanong05:03:05

@thedavidmeister: that looks like you’re dereferencing an atom within an atom. Can you try dereferencing that?

levitanong05:03:14

like, :input #(prn @@%)

thedavidmeister05:03:35

"#<Cell: <#C07V8N22C>/DB {:schema {}, :datoms []}>" index.html.js:593:551
"nil" index.html.js:593:551
"#datascript/DB {:schema {}, :datoms []}" index.html.js:593:551
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. index.html.js:15:0
Error: No protocol method IDeref.-deref defined for type string: Y index.html.js:27:287
Error: No protocol method IDeref.-deref defined for type string: Yf index.html.js:27:287
Error: No protocol method IDeref.-deref defined for type string: Yf< index.html.js:27:287
Error: No protocol method IDeref.-deref defined for type string: Yf<a index.html.js:27:287
Error: No protocol method IDeref.-deref defined for type string: Yf<aZ

levitanong06:03:04

can you try :input #(.log js/console @%)?

levitanong06:03:14

the javascript log sometimes gives more information than prn

thedavidmeister06:03:45

i’ll try that now

levitanong06:03:45

lemme know what comes out simple_smile

thedavidmeister06:03:11

mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create index.html.js:455:250
"#<Cell: <#C07V8N22C>/DB {:schema {}, :datoms []}>" index.html.js:593:551
"nil" index.html.js:593:551
"#datascript/DB {:schema {}, :datoms []}" index.html.js:593:551
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. index.html.js:15:0
")" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )] 536870913] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f] 536870914] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f2] 536870915] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2$" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f2$] 536870916] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2$I" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f2$I] 536870917] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2$I>" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f2$I>] 536870918] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2$I>}" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f2$I>}] 536870919] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2$I>}m" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f2$I>}m] 536870920] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2$I>}m!" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f2$I>}m!] 536870921] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2$I>}m!x" index.html.js:1348:334
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String )f2$I>}m!x] 536870922] [1 :list-id 1 536870913]]}" index.html.js:593:551
")f2$I>}m!xQ" index.html.js:1348:334

thedavidmeister06:03:49

so, that’s from the tests

thedavidmeister06:03:52

#<Cell: <#C07V8N22C>/DB {:schema {}, :datoms []}>
index.html.js:598 nil
index.html.js:598 <#C07V8N22C>/DB {:schema {}, :datoms []}
index.html.js:1354 a
index.html.js:598 <#C07V8N22C>/DB {:schema {}, :datoms [[1 :data "a" 536870913] [1 :list-id 1 536870913]]}
index.html.js:1354 as
index.html.js:598 <#C07V8N22C>/DB {:schema {}, :datoms [[1 :data "as" 536870914] [1 :list-id 1 536870913]]}
index.html.js:1354 asd
index.html.js:598 <#C07V8N22C>/DB {:schema {}, :datoms [[1 :data "asd" 536870915] [1 :list-id 1 536870913]]}
index.html.js:1354 asdf
index.html.js:598 <#C07V8N22C>/DB {:schema {}, :datoms [[1 :data "asdf" 536870916] [1 :list-id 1 536870913]]}

thedavidmeister06:03:01

that’s from me opening up chrome and typing in a few things by hand

thedavidmeister06:03:38

(i see the same thing in firefox)

thedavidmeister06:03:14

"a" index.html.js:1354:334
"#datascript/DB {:schema {}, :datoms [[1 :data "a" 536870913] [1 :list-id 1 536870913]]}" index.html.js:598:551
"as" index.html.js:1354:334
"#datascript/DB {:schema {}, :datoms [[1 :data "as" 536870914] [1 :list-id 1 536870913]]}" index.html.js:598:551
"asd" index.html.js:1354:334
"#datascript/DB {:schema {}, :datoms [[1 :data "asd" 536870915] [1 :list-id 1 536870913]]}”

thedavidmeister06:03:41

so when i console log, it looks the same but when I prn it looks different

levitanong06:03:10

so your tests do not match the usage?

thedavidmeister06:03:28

i do “send keys"

thedavidmeister06:03:42

and the event that comes through has that string object thing

thedavidmeister06:03:51

which looks exactly like a string when you console log

thedavidmeister06:03:56

but different in a prn

thedavidmeister06:03:03

and everything appears to work fine

thedavidmeister06:03:12

until you reload the page, and it tries to read from local storage

thedavidmeister06:03:17

Error: Could not find tag parser for object in ("inst" "uuid" "queue" "js" "tailrecursion.priority-map" "datascript/Datom" "datascript/DB") index.html.js:530:303

levitanong06:03:29

i wonder if that’s a clojurescript/javascript interop thing

levitanong06:03:47

afaik, clojurescript’s strings are slightly different from javascript’s strings.

levitanong06:03:57

lemme double check

thedavidmeister06:03:25

well, i thought maybe what i need is a tag parser for these string objects?

thedavidmeister06:03:32

(I don’t know how to do that ;P)

levitanong06:03:02

so you’re saving the input values into local storage, and then trying to read it at a later time?

thedavidmeister06:03:43

(def conn (local-storage (du/conn-cell) ::conn-state))

thedavidmeister06:03:50

yeah, just a cell

thedavidmeister06:03:55

with a datascript db in it

levitanong06:03:11

ooh, that’s an interesting idea you have there

thedavidmeister06:03:21

but datascript just does the same thing that prn does

thedavidmeister06:03:42

but for some reason it can’t read what it writes

levitanong06:03:19

i’m not actually sure you can save something as complex as a datascript db into local storage, because it’s a very simple key-value storage

thedavidmeister06:03:33

oh it works fine

thedavidmeister06:03:45

i mean, i thought it was 😛

thedavidmeister06:03:58

this is the first time i’ve had troubles with that bit

levitanong06:03:59

haha! lemme look at the error messages again

thedavidmeister06:03:06

i thought that part of the point of datascript is that you can serialise it, pass it around, and then unserialise it later

thedavidmeister06:03:03

at first i thought the problem was in datascript

levitanong06:03:09

Oh, I was under the impression that a datascript db implemented some functions. In the past I’ve experimented with trying to save classes to local storage, and gotten into trouble because the function definitions became stringified

thedavidmeister06:03:19

but when I saw a vanilla prn mimic the issue

thedavidmeister06:03:22

i wasn’t so sure...

levitanong06:03:39

may i see your code? 😛

levitanong06:03:05

i think i need to be able to tinker around to see if there is something in my past experience that matches this case

thedavidmeister06:03:28

not sure if the issue is in master, i’m working on a separate branch

thedavidmeister06:03:37

that would benefit a lot from the if-tpl by the way!

thedavidmeister06:03:21

i figured that i can load “nice to have” resources after window load by simply doing (cell= (if window-loaded? (some-slow-thing)))

thedavidmeister06:03:32

oh, also, another clue

thedavidmeister06:03:43

the issue only seems to appear when optimisations are set to advanced

levitanong06:03:58

If you like, you can just add both the if-tpl* function and if-tpl macro in one of your utility namespaces. simple_smile If the macro thing is a hassle, you can just use if-tpl* and just pass the templates as functions. That’s all the if-tpl macro does anyway, turn the templates in to function to prevent them from being evaluated prematurely.

thedavidmeister06:03:16

i did consider that

levitanong06:03:50

if the problem appears only when it’s optimized, I doubt I’ll be able to figure that out. Waaaaay beyond my experience.

levitanong06:03:00

so curious though.

levitanong06:03:19

it seems like the stringified version of the string object is being passed instead of the string object itself

levitanong06:03:33

i’m guessing that happens during serialization

thedavidmeister06:03:33

getting blocked on this string thing failing my tests 😞

thedavidmeister06:03:15

a great example of tests forcing you to pay attention though 😛

levitanong06:03:12

if you enable the optimizations, is your prn in your :input still doing that thing?

thedavidmeister06:03:21

good point, i’ll turn them off and check

levitanong06:03:16

I’m asking because there may be a separate issue with your input. I’m trying it out with my own project, and I’m not getting the weird #object[String thing.

levitanong06:03:37

also, would you perchance be overriding a do! multimethod for :input?

thedavidmeister06:03:29

"" "" core.js:130:8
"#datascript/DB {:schema {}, :datoms [[1 :data " " 536870913] [1 :list-id 1 536870913]]}" core.js:130:8
" s" lists.js:76:1
"" s"" core.js:130:8
"#datascript/DB {:schema {}, :datoms [[1 :data " s" 536870914] [1 :list-id 1 536870913]]}" core.js:130:8
" s!" lists.js:76:1
"" s!"" core.js:130:8
"#datascript/DB {:schema {}, :datoms [[1 :data " s!" 536870915] [1 :list-id 1 536870913]]}" core.js:130:8
" s!T" lists.js:76:1
"" s!T"" core.js:130:8
"#datascript/DB {:schema {}, :datoms [[1 :data " s!T" 536870916] [1 :list-id 1 536870913]]}" core.js:130:8
" s!T\" lists.js:76:1
"" s!T\\"" core.js:130:8
"#datascript/DB {:schema {}, :datoms [[1 :data " s!T\\" 536870917] [1 :list-id 1 536870913]]}" core.js:130:8
" s!T\K" lists.js:76:1
"" s!T\\K"" core.js:130:8
"#datascript/DB {:schema {}, :datoms [[1 :data " s!T\\K" 536870918] [1 :list-id 1 536870913]]}" core.js:130:8
" s!T\K9" lists.js:76:1
"" s!T\\K9””

thedavidmeister06:03:35

no, not overriding do!

thedavidmeister06:03:05

so that’s a log, then a prn, then a prn of datascript db

thedavidmeister06:03:23

so what’s weird is the double in the prn

levitanong06:03:04

ah, .log really does that. I think it’s part of javascript’s pretty printing

levitanong06:03:41

so this is with optimizations off yeah?

levitanong06:03:03

and it does seem like printing of the input is fine

thedavidmeister06:03:19

prn looks like "" s”"

levitanong06:03:31

oh wait, yeah that’s weird

levitanong06:03:06

a string rendered on .log isn’t supposed to have quotes

thedavidmeister06:03:39

but also, see how what goes into datascript is still a string?

levitanong06:03:09

does this still happen if you start off with a blank project, and you have a simple input?

thedavidmeister06:03:10

that was from the tests

levitanong06:03:31

or maybe… may I see your tests?

levitanong06:03:39

maybe send key is doing something weird

thedavidmeister06:03:59

(deftest local-storage-works
  "Check that text entered into an input remains on page reload"
  (let [s (reduce str (gen/sample (gen/not-empty gen/string-ascii)))]
    (Thread/sleep 1000)
    (send-keys (first (inputs)) s)
    (Thread/sleep 100000)
    (prn (inputs))
    (to "")
    (take-screenshot :file "./screenshot.png")
    (Thread/sleep 100000)
    (prn (inputs))))

thedavidmeister06:03:05

lots of funky debug

thedavidmeister06:03:07

but you get the idea 😛

levitanong06:03:40

wow that actually looks pretty cool. Your testing thing can take screenshots!?

levitanong06:03:53

so what is the code for send-keys?

dm306:03:24

(gen/sample (gen/not-empty gen/string-ascii))) <- this will produce things like " s!T\\"

thedavidmeister06:03:56

maybe it’s an encoding thing?

levitanong06:03:06

oh, @dm3 do you think the gen/sample is producing the extraneous quotes?

thedavidmeister06:03:27

maybe relevant, maybe not

dm306:03:20

ah, the quotes

dm306:03:31

if it produces a string

dm306:03:40

which you pr-str

dm306:03:46

then it will preserve the quotes

dm306:03:08

so it seems you're sending quotes to the input field as input

levitanong06:03:18

mystery solved! 😄

thedavidmeister06:03:45

hang on, i’ll prn from the server side

thedavidmeister06:03:49

what it sends through

thedavidmeister06:03:12

"=rdhgz6nVAuwj4B$S*8y65x”

thedavidmeister06:03:36

"=" lists.js:76:1
""="" core.js:130:8
"#datascript/DB {:schema {}, :datoms [[1 :data "=" 536870913] [1 :list-id 1 536870913]]}" core.js:130:8
"=r" lists.js:76:1
""=r"" core.js:130:8
"#datascript/DB {:schema {}, :datoms [[1 :data "=r" 536870914] [1 :list-id 1 536870913]]}”

levitanong06:03:36

yeah that looks like exactly what @dm3 described

thedavidmeister06:03:38

hmm, I just tried hardcoding to ”foo” in the test

thedavidmeister06:03:45

"#<Cell: <#C07V8N22C>/DB {:schema {}, :datoms []}>" index.html.js:593:551
"nil" index.html.js:593:551
"#datascript/DB {:schema {}, :datoms []}" index.html.js:593:551
Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. index.html.js:15:0
"f" index.html.js:1348:334
"#object[String f]" index.html.js:593:551
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String f] 536870913] [1 :list-id 1 536870913]]}" index.html.js:593:551
"fo" index.html.js:1348:334
"#object[String fo]" index.html.js:593:551
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String fo] 536870914] [1 :list-id 1 536870913]]}" index.html.js:593:551
"foo" index.html.js:1348:334
"#object[String foo]" index.html.js:593:551
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String foo] 536870915] [1 :list-id 1 536870913]]}" index.html.js:593:551

thedavidmeister06:03:12

(send-keys (first (inputs)) "foo”)

dm307:03:29

it tries to print the object somewhere in your code

dm307:03:49

hence the foo -> #object[String foo] transition

dm307:03:05

or is it different output mechanism?

thedavidmeister07:03:23

yeah, I’m doing a prn of the db

thedavidmeister07:03:42

but it only does that with advanced optimisations on

thedavidmeister07:03:45

and it causes an error

levitanong07:03:47

is advanced optimizations a datascript thing or a boot thing?

thedavidmeister07:03:56

i thought it was just clojurescript

thedavidmeister07:03:07

i could try a different version

thedavidmeister07:03:56

do you guys know how to make a tag parser?

thedavidmeister07:03:11

it seems like if i could just make it read that #object[String x] back into a string

thedavidmeister07:03:14

this would be all fixed

levitanong07:03:52

I just read up on the advanced optimizations. It is indeed clojurescript

levitanong07:03:05

Dunno, I think maybe it’s worth figuring out how to prevent the string from being printed onto the code

levitanong07:03:31

seems like that would cause a few more issues down the line

thedavidmeister07:03:41

:input #(d/transact! s/conn [{ :list-id list-id
                                         :data @%
                                         :db/id (if-not (= :new @id) @id)}]))

thedavidmeister07:03:46

that’s my code

thedavidmeister07:03:19

nothing else puts anything into this db

levitanong07:03:44

but inputting it manually works fine, right?

levitanong07:03:09

then doesn’t that imply an issue with send-keys?

thedavidmeister07:03:38

it means send-keys is doing something that my browser doesn’t when i type

thedavidmeister07:03:10

but i don’t know if that means send-keys is doing something “wrong” or just “not what dave’s laptop does when he types"

thedavidmeister07:03:43

if i knew what the heck a #object[String x] is

thedavidmeister07:03:59

i’d have a better idea of whether this is a real problem in my app, or something invented by selenium

levitanong07:03:59

oh, that’s this:

levitanong07:03:03

cljs.user=> (type "Hello")
#object[String "function String() {
    [native code]
}”]

levitanong07:03:35

I’m using planck here as a cljs repl

levitanong07:03:42

i’m guessing that’s clojure(script)’s representation of js classes

levitanong07:03:19

cljs.user=> (type (clj->js {}))
#object[Object "function Object() {
    [native code]
}”]

thedavidmeister07:03:16

ah, so it’s taking something that was cljs and trying to turn it into native js?

thedavidmeister07:03:23

or the other way around?

levitanong07:03:45

at this point, I don’t know 😛

levitanong07:03:19

(prn (js/Array.))

levitanong07:03:54

(prn (js/Array. “hello”))

levitanong07:03:06

it returns #object[String hello]

levitanong07:03:18

so it’s trying to print a native js thing in a clojure way

levitanong07:03:40

so i think one way to get around this

thedavidmeister07:03:42

so, i have a js string in my db

levitanong07:03:45

is to wrap it in (str)

thedavidmeister07:03:46

but need a cljs string?

thedavidmeister07:03:55

yeah, see i tried that

thedavidmeister07:03:58

it didn’t work, lol

levitanong07:03:36

have you tried (js->clj) ?

thedavidmeister07:03:40

i’ll try again with the debug and post the results

thedavidmeister07:03:19

"f" index.html.js:1348:334
"#object[String f]" index.html.js:593:551
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String f] 536870913] [1 :list-id 1 536870913]]}" index.html.js:593:551
"fo" index.html.js:1348:334
"#object[String fo]" index.html.js:593:551
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String fo] 536870914] [1 :list-id 1 536870913]]}”

thedavidmeister07:03:46

the console log says “f"

levitanong07:03:15

what are you doing here? 😛

thedavidmeister07:03:27

:input #(do (.log js/console (str @%)) (prn (str @%))
                    (d/transact! s/conn [{ :list-id list-id
                                           :data (str @%)
                                           :db/id (if-not (= :new @id) @id)}]))

thedavidmeister07:03:30

with optimisations on

thedavidmeister07:03:59

looks like str is actually causing this

levitanong07:03:49

that’s really odd

levitanong07:03:43

i’ve tried a few times. for me, only str works o_O

thedavidmeister07:03:13

it must be something in selenium

thedavidmeister07:03:17

trying cljs 1.8.34 now

thedavidmeister07:03:24

i’ll try js->clj

levitanong07:03:07

maybe it isn’t such a problem

levitanong07:03:18

what if, when accessing, you can just (str)

levitanong07:03:41

and keep it as #object[String x] in the db

thedavidmeister07:03:48

it errors as soon as the page loads and the local storage cell does its thing

levitanong07:03:55

it’s so odd. I wonder why (js/String “hello”) and “hello” are rendered so differently

levitanong07:03:01

they seem to have the same methods

levitanong07:03:47

they have the same constructor too

levitanong07:03:57

i guess.. try (.valueOf (js/String. “hello”))?

thedavidmeister07:03:45

yeah i’ll try that

thedavidmeister08:03:18

the plot thickens

thedavidmeister08:03:28

"f" index.html.js:1379:334
"#object[String bar]" index.html.js:625:559
"#object[String f]" index.html.js:625:559
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String f] 536870913] [1 :list-id 1 536870913]]}" index.html.js:625:559
"fo" index.html.js:1379:334
"#object[String bar]" index.html.js:625:559
"#object[String fo]" index.html.js:625:559
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String fo] 536870914] [1 :list-id 1 536870913]]}”

thedavidmeister08:03:40

:input #(do
                    (.log js/console (.valueOf (js/String. @%)))
                    (prn (.valueOf (js/String. "bar")))
                    (prn (.valueOf (js/String. @%)))
                    (d/transact! s/conn [{ :list-id list-id
                                           :data (.valueOf (js/String. @%))
                                           :db/id (if-not (= :new @id) @id)}]))

thedavidmeister08:03:04

maybe we’re going the wrong way

thedavidmeister08:03:14

and it’s the primitive string that doesn’t work

thedavidmeister08:03:43

String [ "f" ] index.html.js:1379:334
"#object[String bar]" index.html.js:625:559
"#object[String f]" index.html.js:625:559
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String f] 536870913] [1 :list-id 1 536870913]]}" index.html.js:625:559
String [ "f", "o" ] index.html.js:1379:334
"#object[String bar]" index.html.js:625:559
"#object[String fo]" index.html.js:625:559
"#datascript/DB {:schema {}, :datoms [[1 :data #object[String fo] 536870914] [1 :list-id 1 536870913]]}”

thedavidmeister08:03:52

removing the .valueOf

levitanong08:03:14

one thing i like doing in cases like this is to slowly remove everything

thedavidmeister08:03:15

what actually is a cljs string

levitanong08:03:44

i have no idea anymore @[email protected]

levitanong08:03:53

maybe it really is just a javascript string literal

levitanong08:03:28

so i’d make a new branch, then delete most of the files that aren’t involved

levitanong08:03:38

and slowly kill off everything until i have the simplest case

thedavidmeister08:03:39

well i did (prn (js/String. "bar”))

thedavidmeister08:03:44

that’s pretty simple

thedavidmeister08:03:54

i got "#object[String bar]”

levitanong08:03:16

yeah, I get that too, but (prn (str (js/String. “bar”))) works for me

levitanong08:03:19

it bring sit back to “bar"

thedavidmeister08:03:53

(prn (.valueOf (js/String. "bar"))) is not the same as (prn (str (js/String. "bar")))

levitanong08:03:20

both give the same result for me

thedavidmeister08:03:02

with advanced compilation on?

levitanong08:03:17

i’m just working on the repl in this case

levitanong08:03:28

i actually don’t know how to turn advanced compilation on 😛

levitanong08:03:37

does it give you different results?

thedavidmeister08:03:20

literally just do this

thedavidmeister08:03:23

(cljs :optimizations :advanced)

thedavidmeister08:03:32

instead of (cljs)

thedavidmeister08:03:09

it minifies all your JS and shrinks it down into a single file

thedavidmeister08:03:20

really good for prod so you don’t have lots of round trips to the server

levitanong08:03:31

thanks for the info 😄 will try it out now

levitanong08:03:17

okay just tried it out on advanced compilation.

levitanong08:03:24

still getting the same values for both .valueOf and str

thedavidmeister08:03:25

😭 doesn’t break when i build it normally

levitanong08:03:16

you get different values?

thedavidmeister08:03:09

i compile and open up firefox, i get ”bar” all the way down

thedavidmeister08:03:25

i run the web tests, with firefox, I get all the weirdness above

levitanong08:03:34

i’m using chrome.

thedavidmeister08:03:10

this is really weird >.<

thedavidmeister08:03:51

i think i need to do more sleuthing and get back to you

thedavidmeister08:03:08

maybe selenium does something to the string object

thedavidmeister08:03:26

although, that would be pretty hectic

thedavidmeister08:03:44

maybe the “solution” is that i just run tests with optimisations off

thedavidmeister08:03:29

ok, not happening in master...

thedavidmeister08:03:32

ok… it’s either google analytics or google fonts

thedavidmeister08:03:38

this is so weird...

thedavidmeister09:03:06

yup, it’s google analytics

thedavidmeister09:03:22

(c/defelem google-analytics
  []
  ; 
  [ (c/script
      "=||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
      ga('create', 'UA-69870255-1', 'auto');
      ga('send', 'pageview');")
    (c/script
      :async true
      :src "")])

thedavidmeister09:03:25

something in here

thedavidmeister09:03:39

i suppose that when my code is minified ga conflicts with something?

thedavidmeister09:03:53

that only affects firefox, and only when running tests?

levitanong09:03:10

let me get this straight

levitanong09:03:21

if you run the thing without the google-analytics, it works fine

levitanong09:03:31

if you run it with, you only get issues when you’re using firefox?

thedavidmeister09:03:19

only when i’m using firefox driven by selenium

thedavidmeister09:03:27

w/o selenium = no bugs

thedavidmeister09:03:55

it’s a combination of selenium + ff + ga + cljs minification

levitanong09:03:05

that is absurdly specific

thedavidmeister09:03:43

i think that something about that combination must be causing the ga global object to conflict with something

levitanong09:03:54

Can you try renaming ga to something else?

thedavidmeister09:03:25

yeah, i’m fiddling with that now

thedavidmeister09:03:58

omg i think it works

thedavidmeister09:03:22

[ (c/script
      "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','','analytics');

      analytics('create', 'UA-69870255-1', 'auto');
      analytics('send', 'pageview');")])

levitanong09:03:22

This really goes way up in my list of weird programming things.

thedavidmeister09:03:46

yeah, so i didn’t have this problem before because i was using cljsjs

levitanong09:03:00

Good job, man!

levitanong09:03:13

Now to figure out where to post the issue. :p

thedavidmeister09:03:13

but that pulls in GA as soon as i have a :requires

thedavidmeister09:03:34

but really, i wanted to let the page load

thedavidmeister09:03:40

then pull in GA after that

thedavidmeister09:03:28

because that + a font from google is adding 400ms+ to my page load

levitanong09:03:06

One thing you can do is looked at the compiled code and do a search for "ga"

levitanong09:03:24

I do know that global variables are renamed in advanced optimization mode.

levitanong09:03:36

Ah I think I get it.

levitanong09:03:17

Because the script itself is a string inside a script elem, it's being executed after the minification is done.

levitanong09:03:45

And since var renaming follows the pattern "a, b, c, ... aa, ab, ... ga" it would inevitably screw things over.

thedavidmeister10:03:00

that’s exactly the problem simple_smile

thedavidmeister10:03:19

and unfortunately, instead of completely blowing up and being obvious

thedavidmeister10:03:25

it did something that looked “almost right"

thedavidmeister10:03:55

@levitanong: thanks heaps for helping simple_smile

levitanong10:03:45

:D happy to help, @thedavidmeister !

dm313:03:37

it seems that switch-tpl and if-tpl should be deep walking macros themselves (like cell=)

dm313:03:09

I tried writing a thing like

(switch-tpl some-type-cell
  :a (render-this value-cell)
  :b (render-that value-cell))
but this doesn't rerender when the value-cell changes

dm313:03:19

or I'm doing something stupid

dm313:03:29

yeah, @levitanong - if I understand correctly, your switch-tpl is supposed to only render a template once and cache it, right?

dm313:03:49

although it does cache the dom nodes together with whatever listeners got attached by Hoplon for cell-related changes

dm313:03:07

so actually it should work! and it does, after I refreshed 😞 sorry for the noise

dm313:03:57

I'd love being able to write multimethods instead of switch-tpl, wonder if that's possible...

jjttjj16:03:19

attempting to quickly tackle the "document defelem" issue that was opened a few days. quick question, is it worth documenting that both attr and children are only optionally bound in when you create a defelem, or is it generally a best practice that at least attrs, or both are always bound?

micha16:03:53

i think it's probably a good idea to at least have two arguments, using _ for the ones you don't use

micha16:03:28

that will ensure that nothing will break with some new version of clojurescript that enforces function arities as clojure does

micha16:03:38

(when you make a thing like (defelem foop [] ...), the function is always called with two arguments. in the current version of cljs it's ok to call it like (foop x y), but in some future version of cljs that will probably be an error)

jjttjj17:03:17

cool makes sense

levitanong18:03:26

Speaking of documenting defelem, I’ve taken the liberty of writing an entry for it in the wiki. I hope you guys don’t mind. https://github.com/hoplon/hoplon/wiki/API-Documentation#defelem

micha18:03:43

@levitanong: :+1: owe you 🍻

dm318:03:26

@micha - I'm guessing you had usecases in Adzerk where you had to generate DOM conditionally, e.g. different forms based on some condition type. How did you handle that, given that (cell= (cond a (form-a) b (form-b))) is not recommended due to potentially generated garbage. What did you do? simple_smile