This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-21
Channels
- # admin-announcements (4)
- # aleph (1)
- # beginners (15)
- # boot (55)
- # braveandtrue (5)
- # cider (20)
- # clara (10)
- # cljs-dev (13)
- # cljsrn (8)
- # clojure (52)
- # clojure-austin (30)
- # clojure-brasil (2)
- # clojure-india (1)
- # clojure-italy (2)
- # clojure-nl (1)
- # clojure-russia (72)
- # clojure-sdn (9)
- # clojure-taiwan (2)
- # clojure-uk (45)
- # clojurebridge (3)
- # clojured (1)
- # clojurescript (46)
- # core-matrix (1)
- # cryogen (1)
- # cursive (43)
- # datascript (12)
- # datomic (57)
- # devcards (54)
- # emacs (6)
- # funcool (21)
- # hoplon (335)
- # jobs (15)
- # jobs-rus (40)
- # ldnclj (2)
- # lein-figwheel (20)
- # off-topic (59)
- # om (157)
- # onyx (29)
- # parinfer (2)
- # pedestal (26)
- # proton (9)
- # protorepl (2)
- # reagent (3)
- # ring-swagger (4)
- # spacemacs (2)
- # untangled (17)
Hello @micha! regarding this https://clojurians.slack.com/archives/hoplon/p1458264274000322
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))
`Have a great night @micha
has anyone seen this "#object[String #;9]”
when dereferencing an event?
like :input #(prn @%)
on a text input
I expect to see ”#;9”
but it’s wrapped in this String object thing in prn
@davidme
@thedavidmeister: that looks like you’re dereferencing an atom within an atom. Can you try dereferencing that?
like, :input #(prn @@%)
kk, 1 sec
no love
"#<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
hmm...
can you try :input #(.log js/console @%)
?
the javascript log sometimes gives more information than prn
yeah good idea
i’ll try that now
lemme know what comes out
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
so, that’s from the tests
#<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]]}
that’s from me opening up chrome and typing in a few things by hand
(i see the same thing in firefox)
well, this
"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]]}”
from firefox
so when i console log, it looks the same but when I prn
it looks different
so your tests do not match the usage?
i do “send keys"
and the event that comes through has that string object thing
which looks exactly like a string when you console log
but different in a prn
and everything appears to work fine
until you reload the page, and it tries to read from local storage
and i get
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
i wonder if that’s a clojurescript/javascript interop thing
afaik, clojurescript’s strings are slightly different from javascript’s strings.
oh really?
lemme double check
well, i thought maybe what i need is a tag parser for these string objects?
(I don’t know how to do that ;P)
so you’re saving the input values into local storage, and then trying to read it at a later time?
(def conn (local-storage (du/conn-cell) ::conn-state))
yeah, just a cell
with a datascript db in it
ooh, that’s an interesting idea you have there
but datascript just does the same thing that prn
does
but for some reason it can’t read what it writes
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
oh it works fine
i mean, i thought it was 😛
this is the first time i’ve had troubles with that bit
haha! lemme look at the error messages again
i thought that part of the point of datascript is that you can serialise it, pass it around, and then unserialise it later
at first i thought the problem was in datascript
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
but when I saw a vanilla prn
mimic the issue
i wasn’t so sure...
may i see your code? 😛
i think i need to be able to tinker around to see if there is something in my past experience that matches this case
not sure if the issue is in master, i’m working on a separate branch
that would benefit a lot from the if-tpl by the way!
i figured that i can load “nice to have” resources after window load by simply doing (cell= (if window-loaded? (some-slow-thing)))
oh, also, another clue
the issue only seems to appear when optimisations are set to advanced
If you like, you can just add both the if-tpl* function and if-tpl macro in one of your utility namespaces. 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.
i did consider that
if the problem appears only when it’s optimized, I doubt I’ll be able to figure that out. Waaaaay beyond my experience.
so curious though.
for now i’m just trying this https://github.com/thedavidmeister/estimate-work/pull/212/files
it seems like the stringified version of the string object is being passed instead of the string object itself
i’m guessing that happens during serialization
getting blocked on this string thing failing my tests 😞
a great example of tests forcing you to pay attention though 😛
hang on
if you enable the optimizations, is your prn
in your :input still doing that thing?
good point, i’ll turn them off and check
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.
also, would you perchance be overriding a do! multimethod for :input?
"" "" 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””
no, not overriding do!
so that’s a log, then a prn, then a prn of datascript db
so what’s weird is the double ”
in the prn
ah, .log really does that. I think it’s part of javascript’s pretty printing
so this is with optimizations off yeah?
and it does seem like printing of the input is fine
prn looks like "" s”"
oh wait, yeah that’s weird
hahaha
a string rendered on .log isn’t supposed to have quotes
but also, see how what goes into datascript is still a string?
so that works
does this still happen if you start off with a blank project, and you have a simple input?
that was from the tests
or maybe… may I see your tests?
maybe send key
is doing something weird
just this atm
(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))))
lots of funky debug
but you get the idea 😛
wow that actually looks pretty cool. Your testing thing can take screenshots!?
so what is the code for send-keys?
maybe it’s an encoding thing?
is ascii right?
oh, @dm3 do you think the gen/sample
is producing the extraneous quotes?
maybe relevant, maybe not
reading...
mystery solved! 😄
hang on, i’ll prn
from the server side
what it sends through
"=rdhgz6nVAuwj4B$S*8y65x”
comes through
"=" 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]]}”
yeah that looks like exactly what @dm3 described
hmm, I just tried hardcoding to ”foo”
in the test
"#<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
(send-keys (first (inputs)) "foo”)
yeah, I’m doing a prn
of the db
but it only does that with advanced optimisations on
and it causes an error
is advanced optimizations a datascript thing or a boot thing?
i thought it was just clojurescript
i could try a different version
do you guys know how to make a tag parser?
it seems like if i could just make it read that #object[String x] back into a string
this would be all fixed
I just read up on the advanced optimizations. It is indeed clojurescript
Dunno, I think maybe it’s worth figuring out how to prevent the string from being printed onto the code
seems like that would cause a few more issues down the line
:input #(d/transact! s/conn [{ :list-id list-id
:data @%
:db/id (if-not (= :new @id) @id)}]))
that’s my code
nothing else puts anything into this db
but inputting it manually works fine, right?
then doesn’t that imply an issue with send-keys?
it means send-keys is doing something that my browser doesn’t when i type
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"
if i knew what the heck a #object[String x]
is
i’d have a better idea of whether this is a real problem in my app, or something invented by selenium
oh, that’s this:
cljs.user=> (type "Hello")
#object[String "function String() {
[native code]
}”]
I’m using planck here as a cljs repl
i’m guessing that’s clojure(script)’s representation of js classes
cljs.user=> (type (clj->js {}))
#object[Object "function Object() {
[native code]
}”]
ah, so it’s taking something that was cljs and trying to turn it into native js?
or the other way around?
at this point, I don’t know 😛
try this
(prn (js/Array.))
(prn (js/Array. “hello”))
it returns #object[String hello]
so it’s trying to print a native js thing in a clojure way
so i think one way to get around this
so, i have a js string in my db
is to wrap it in (str)
but need a cljs string?
exactly
yeah, see i tried that
it didn’t work, lol
have you tried (js->clj) ?
i’ll try again with the debug and post the results
oooh, a clue
"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]]}”
the console log says “f"
what are you doing here? 😛
: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)}]))
with optimisations on
looks like str
is actually causing this
that’s really odd
i’ve tried a few times. for me, only str
works o_O
it must be something in selenium
trying cljs 1.8.34 now
no dice
i’ll try js->clj
maybe it isn’t such a problem
what if, when accessing, you can just (str)
and keep it as #object[String x]
in the db
how to do that?
it errors as soon as the page loads and the local storage cell does its thing
it’s so odd. I wonder why (js/String “hello”) and “hello” are rendered so differently
they seem to have the same methods
they have the same constructor too
maybe this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
ooooh
interesting
i guess.. try (.valueOf (js/String. “hello”))
?
yeah i’ll try that
the plot thickens
"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]]}”
: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)}]))
maybe we’re going the wrong way
and it’s the primitive string that doesn’t work
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]]}”
removing the .valueOf
one thing i like doing in cases like this is to slowly remove everything
what actually is a cljs string
i have no idea anymore @_@
maybe it really is just a javascript string literal
so i’d make a new branch, then delete most of the files that aren’t involved
and slowly kill off everything until i have the simplest case
well i did (prn (js/String. "bar”))
that’s pretty simple
i got "#object[String bar]”
yeah, I get that too, but (prn (str (js/String. “bar”)))
works for me
it bring sit back to “bar"
(prn (.valueOf (js/String. "bar")))
is not the same as (prn (str (js/String. "bar")))
both give the same result for me
with advanced compilation on?
i’m just working on the repl in this case
i actually don’t know how to turn advanced compilation on 😛
does it give you different results?
literally just do this
(cljs :optimizations :advanced)
in boot
instead of (cljs)
it minifies all your JS and shrinks it down into a single file
really good for prod so you don’t have lots of round trips to the server
thanks for the info 😄 will try it out now
okay just tried it out on advanced compilation.
still getting the same values for both .valueOf and str
😭 doesn’t break when i build it normally
whyyyy
you get different values?
i compile and open up firefox, i get ”bar”
all the way down
i run the web tests, with firefox, I get all the weirdness above
i’m using chrome.
this is really weird >.<
i think i need to do more sleuthing and get back to you
maybe selenium does something to the string object
although, that would be pretty hectic
maybe the “solution” is that i just run tests with optimisations off
ok, not happening in master...
something in this diff… https://github.com/thedavidmeister/estimate-work/pull/212/files
ok… it’s either google analytics or google fonts
this is so weird...
yup, it’s google analytics
(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 "")])
something in here
i suppose that when my code is minified ga
conflicts with something?
that only affects firefox, and only when running tests?
let me get this straight
if you run the thing without the google-analytics, it works fine
if you run it with, you only get issues when you’re using firefox?
only when i’m using firefox driven by selenium
w/o selenium = no bugs
it’s a combination of selenium + ff + ga + cljs minification
that is absurdly specific
hahaha
i think that something about that combination must be causing the ga
global object to conflict with something
Can you try renaming ga to something else?
yeah, i’m fiddling with that now
omg i think it works
[ (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');")])
This really goes way up in my list of weird programming things.
yeah, so i didn’t have this problem before because i was using cljsjs
Good job, man!
Now to figure out where to post the issue. :p
but that pulls in GA as soon as i have a :requires
but really, i wanted to let the page load
then pull in GA after that
because that + a font from google is adding 400ms+ to my page load
probably right here https://github.com/hoplon/hoplon/issues/68
One thing you can do is looked at the compiled code and do a search for "ga"
I do know that global variables are renamed in advanced optimization mode.
Ah I think I get it.
Because the script itself is a string inside a script elem, it's being executed after the minification is done.
And since var renaming follows the pattern "a, b, c, ... aa, ab, ... ga" it would inevitably screw things over.
that’s exactly the problem
and unfortunately, instead of completely blowing up and being obvious
it did something that looked “almost right"
@levitanong: thanks heaps for helping
:D happy to help, @thedavidmeister !
tests are green
Awyis
it seems that switch-tpl
and if-tpl
should be deep walking macros themselves (like cell=
)
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
changesyeah, @levitanong - if I understand correctly, your switch-tpl
is supposed to only render a template once and cache it, right?
although it does cache the dom nodes together with whatever listeners got attached by Hoplon for cell-related changes
I'd love being able to write multimethods instead of switch-tpl
, wonder if that's possible...
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?
i think it's probably a good idea to at least have two arguments, using _
for the ones you don't use
that will ensure that nothing will break with some new version of clojurescript that enforces function arities as clojure does
(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)
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
@levitanong: 👍 owe you 🍻
@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?