-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
events/listen! does not work with :optimizations :advanced (??) #57
Comments
deg, you've probably resolved this by now, but this looks like normal behavior to me. Domina returns a wrapped event object to the listen! function argument. Have you tried calling anything like "raw-event" or whatnot on the object in your function, and examining that output? https://github.com/levand/domina#event-objects For example, to get the clicked element, you would call (current-target event-obj). EDIT: the perplexing thing to me is that this works at all when you don't have advanced compilation on, because as far as I can tell this is proper behavior... |
(Whoops, I thought I answered this a few days ago, but I apparently never hit send, or something) I'll need to look at this more carefully tomorrow, but I've just confirmed that the problem still occurs. The relevant code has morphed a bit since I first submitted the report; it's now:
Works fine with
|
Ok, I've looked at this a bit more carefully. I've verified that when I compile So, I guess the key question is: ... It looks like the problem is something in the compilation of Domina's Event defprotocol that goes awry in advanced mode. First, for reference, here is the code generated in :simple mode:
Here is the code generated in :advanced mode:
In simple mode, the first line succeeds, and the target is returned immediately. In advanced mode, |
a itself seems to the object jQuery.fn.jQuery.init[1] Why is jQuery in there? This should be straight domina/Google Closure objects that you're dealing with. This is starting to smell like namespace collisions in advanced mode... What other javascript/Clojurescript libs are you using? Assuming you're not--do you get the same issues when you isolate this bit of code to a separate project, with nothing but Domina included? |
Sorry to not answer this: Am I doing something wrong in my project.clj and/or my call to listen!, or does Domina not yet fully support :advanced mode? Domina most definitely supports advanced mode--I'm using it now in a production app. So there is probably something going on with the collection of libs you are including/namespaces you're importing into your code/etc. (based on my own experiences getting advanced compilation working w/domina and other libs). |
Thanks; good to know that the problem is contained. I'll start pruning/testing my project.clj later today -- have to run to a few meetings first. I'll let you know what I find; hope it's just some simple collision to add to the readme. Meanwhile, here's my project.clj, in case something obvious catches your eye. (Sorry, it's a bit of a mess, assembled from too many different sources and failed experiments. I'm aiming to clean it up too, in this round of testing).
|
Problem found; the clue was your comment about jquery. My project uses bootstrap.js which, in turn, requires the inclusion of jquery.js. Fortunately, the only features of bootstrap I actually use are in the css, so this change has near-zero impact on my project. The control that showed the problem was a bootstrap button. So, I assume that the only connection to domina is that the domina call happened to be the first interesting access of that object. Looks like this issue can be closed as a red herring. Sorry! But, for my future reference, do you happen to know if either jquery or bootstrap are known not to work with advanced compilation? |
Oh, great! Glad to hear that you figured it out. But, for my future reference, do you happen to know if either jquery or bootstrap are known not to work with advanced compilation? Well, I can't speak to bootstrap, but considering that jayq does (we have it in our project, although we deprecated it in favor of domina...for now), and bootstrap is mostly jQuery code (right?) it should work. Assuming you've got the right externs (https://developers.google.com/closure/compiler/docs/api-tutorial3#externs) set up it should be okay. |
Yeah, umm, about those externs... (embarrassed grin). No, I didn't have any, but discovered the need yesterday when I Googled for jquery and closure. But, since I don't actually need the bootstrap or jquery js files at all, I just diked out the two references and don't need to learn the extern syntax until next time. Thanks again. All's well that ends. |
Yeah--I've really only ever needed the externs in a limited way, when I'm calling JS code in my CLJS, and most of the time I wrap stuff up in a function or two and that does it. In any case, glad to hear things are working. |
I am closing this issue because the resolution was outside of domina. |
This seems weird enough that I assume the problem lies in my code, but I don't see what I'm doing wrong...
My code works correctly until I compile it with :optimizations :advanced. Then, the domina event listener seems to return a raw object, rather than the DOM node I expected:
I click on the page, and the console shows:
The text was updated successfully, but these errors were encountered: