{"action":"created","issue":{"url":"https://api.github.com/repos/Shopify/turbograft/issues/77","labels_url":"https://api.github.com/repos/Shopify/turbograft/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/Shopify/turbograft/issues/77/comments","events_url":"https://api.github.com/repos/Shopify/turbograft/issues/77/events","html_url":"https://github.com/Shopify/turbograft/pull/77","id":59850325,"number":77,"title":"Remove nodes with jQuery if available","user":{"login":"DrewMartin","id":1687807,"avatar_url":"https://avatars.githubusercontent.com/u/1687807?v=3","gravatar_id":"","url":"https://api.github.com/users/DrewMartin","html_url":"https://github.com/DrewMartin","followers_url":"https://api.github.com/users/DrewMartin/followers","following_url":"https://api.github.com/users/DrewMartin/following{/other_user}","gists_url":"https://api.github.com/users/DrewMartin/gists{/gist_id}","starred_url":"https://api.github.com/users/DrewMartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrewMartin/subscriptions","organizations_url":"https://api.github.com/users/DrewMartin/orgs","repos_url":"https://api.github.com/users/DrewMartin/repos","events_url":"https://api.github.com/users/DrewMartin/events{/privacy}","received_events_url":"https://api.github.com/users/DrewMartin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-03-04T19:42:06Z","updated_at":"2015-03-04T21:26:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Shopify/turbograft/pulls/77","html_url":"https://github.com/Shopify/turbograft/pull/77","diff_url":"https://github.com/Shopify/turbograft/pull/77.diff","patch_url":"https://github.com/Shopify/turbograft/pull/77.patch"},"body":"Because of how we replace nodes anything that has jQuery event handlers attached (explicitly attached, not through Twine) will cause the listening object to leak. For example our Form object does several $.on calls in the constructor and because of this it will never be cleaned up. jQuery event handlers are are only cleaned up when you use jQuery methods to remove the nodes.\r\n\r\nWhen calling [remove](http://api.jquery.com/remove/) and [replaceWith](http://api.jquery.com/replaceWith/) \"all bound events and jQuery data associated with the elements are removed\"\r\n\r\nReview\r\n@Thibaut @qq99 @kristianpd @arthurnn \r\nWe should probably push this upstream to turbolinks. Glancing at their code I believe it will have the same problem\r\nAlso I'm not sure how to write tests for memory leaks"},"comment":{"url":"https://api.github.com/repos/Shopify/turbograft/issues/comments/77252506","html_url":"https://github.com/Shopify/turbograft/pull/77#issuecomment-77252506","issue_url":"https://api.github.com/repos/Shopify/turbograft/issues/77","id":77252506,"user":{"login":"DrewMartin","id":1687807,"avatar_url":"https://avatars.githubusercontent.com/u/1687807?v=3","gravatar_id":"","url":"https://api.github.com/users/DrewMartin","html_url":"https://github.com/DrewMartin","followers_url":"https://api.github.com/users/DrewMartin/followers","following_url":"https://api.github.com/users/DrewMartin/following{/other_user}","gists_url":"https://api.github.com/users/DrewMartin/gists{/gist_id}","starred_url":"https://api.github.com/users/DrewMartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrewMartin/subscriptions","organizations_url":"https://api.github.com/users/DrewMartin/orgs","repos_url":"https://api.github.com/users/DrewMartin/repos","events_url":"https://api.github.com/users/DrewMartin/events{/privacy}","received_events_url":"https://api.github.com/users/DrewMartin/received_events","type":"User","site_admin":false},"created_at":"2015-03-04T21:26:26Z","updated_at":"2015-03-04T21:26:26Z","body":"Yeah, and you have to use one of jQuery's methods to clean them up (html, remove, replaceWith, etc)"}}