Skip to content
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

Fix for Issue #6 Event handler removal fails. #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

cliffordbeshers
Copy link
Contributor

#6

Attaching an event handler with JavaScript.JQuery.on returns an IO () that is supposed to remove the handler. JavaScript.JQuery.on calls JavaScript.JQuery.Internal.jq_on, which wraps the provided callback in a closure using h$jquery_makeListener. But the original callback is what is passed to JavaScript.JQuery.off. In order for $().off to remove the handler, the arguments must be identical.

I have modified by .on and .one and jq_on so that the closure created by j$jquery_makeListener is returned by jq_on. This fixes the removal. See the program https://github.com/cliffordbeshers/vdom-event/blob/master/TestDetach.hs as proof. Click the left button to see a message appear, the right button to remove the handler from the left. Before merging this branch, the left button will continue to append messages to the DOM.

This code needs review.
a) I modified the type signatures of jq_on and on. They compile, but I am not sure if they are the tightest they could be.
b) After the event handler is turned of, the cb callback value is released. Should this now be the value returned by jq_on, called cb' in the code? I left it as it was originally, but fear this introduces a leak.

@bergey
Copy link
Contributor

bergey commented Apr 16, 2016

The removal code looks good to me, and the type of jq_on. I don't know how memory management for callbacks works.

@mgsloan can you look at the memory issue, or CC someone who can?

@mgsloan
Copy link
Contributor

mgsloan commented Apr 18, 2016

The fixes are already on master. The addition of ajaxRaw is not, though, that part could be rebased on master (lots of changes happened on master after this change).

@cliffordbeshers
Copy link
Contributor Author

@mgsloan Not sure what fixes you were referring to, but I tried this again today and I see change, the event removal still isn't fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants