{"action":"created","issue":{"url":"https://api.github.com/repos/LeadDyno/intercooler-js/issues/121","repository_url":"https://api.github.com/repos/LeadDyno/intercooler-js","labels_url":"https://api.github.com/repos/LeadDyno/intercooler-js/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/LeadDyno/intercooler-js/issues/121/comments","events_url":"https://api.github.com/repos/LeadDyno/intercooler-js/issues/121/events","html_url":"https://github.com/LeadDyno/intercooler-js/issues/121","id":176992375,"number":121,"title":"DOM Swaps appear to be leaking memory","user":{"login":"OvermindDL1","id":401605,"avatar_url":"https://avatars.githubusercontent.com/u/401605?v=3","gravatar_id":"","url":"https://api.github.com/users/OvermindDL1","html_url":"https://github.com/OvermindDL1","followers_url":"https://api.github.com/users/OvermindDL1/followers","following_url":"https://api.github.com/users/OvermindDL1/following{/other_user}","gists_url":"https://api.github.com/users/OvermindDL1/gists{/gist_id}","starred_url":"https://api.github.com/users/OvermindDL1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OvermindDL1/subscriptions","organizations_url":"https://api.github.com/users/OvermindDL1/orgs","repos_url":"https://api.github.com/users/OvermindDL1/repos","events_url":"https://api.github.com/users/OvermindDL1/events{/privacy}","received_events_url":"https://api.github.com/users/OvermindDL1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-14T19:04:00Z","updated_at":"2016-09-16T16:11:54Z","closed_at":null,"body":"Continued from https://github.com/LeadDyno/intercooler-js/issues/118.\r\n\r\nDOM Swaps seem to be using jQuery's `replaceWith` call, which does not destroy the old element, thus:\r\n1. The old element still exists.\r\n2. The old element is leaking memory (need to properly destroy it as active javascript handlers attached to it will cause leaking).\r\n3. The line where you have `target.replaceWith(contentToSwap);` and then `fireReadyStuff($(target));`, which calls the `ready` callbacks, it being called with the old element.\r\n4. Thus the fireReadyStuff should be given both the old and new elements, and then the old element should be properly destroyed so javascript event handlers attached to them (like via intercooler or mdl) do not keep it around eating memory.\r\n"},"comment":{"url":"https://api.github.com/repos/LeadDyno/intercooler-js/issues/comments/247641609","html_url":"https://github.com/LeadDyno/intercooler-js/issues/121#issuecomment-247641609","issue_url":"https://api.github.com/repos/LeadDyno/intercooler-js/issues/121","id":247641609,"user":{"login":"carsongross","id":469183,"avatar_url":"https://avatars.githubusercontent.com/u/469183?v=3","gravatar_id":"","url":"https://api.github.com/users/carsongross","html_url":"https://github.com/carsongross","followers_url":"https://api.github.com/users/carsongross/followers","following_url":"https://api.github.com/users/carsongross/following{/other_user}","gists_url":"https://api.github.com/users/carsongross/gists{/gist_id}","starred_url":"https://api.github.com/users/carsongross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carsongross/subscriptions","organizations_url":"https://api.github.com/users/carsongross/orgs","repos_url":"https://api.github.com/users/carsongross/repos","events_url":"https://api.github.com/users/carsongross/events{/privacy}","received_events_url":"https://api.github.com/users/carsongross/received_events","type":"User","site_admin":false},"created_at":"2016-09-16T16:11:54Z","updated_at":"2016-09-16T16:11:54Z","body":":)  \n\nJust sat down at my desk.  I will try to sign up for gitter now...\n\nCheers,\nCarson\n\nOn September 16, 2016 at 8:15:04 AM, OvermindDL1 (notifications@github.com) wrote:\n\nIt seems different callbacks are called at different times, but there is nothing that reliably gives me the old element in all cases (pre-swap) and the new element (post-swap) both, such calls would fix the other event handlers. :-)\n\nHow about an Intercooler.removedElementsPreSwap(function(elems){}) and an Intercooler.removedElementsPostSwap(function(elems){}) and an Intercooler.addedElementsPreSwap(function(elems){}) and an Intercooler.addedElementsPostSwap(function(elems){})? That would handle all my cases. :-)\n\nOr combine them for fewer calls via Intercooler.elementsPreSwap(function(oldElems, newElems){}) and an Intercooler.elementsPostSwap(function(oldElems, newElems){}), with undefined for the argument where one or the other is not valid (or instead of invalid an empty jQuery $() container, although undefined would probably be better even if it requires doing a test in the user code).\n\n—\nYou are receiving this because you commented.\nReply to this email directly, view it on GitHub, or mute the thread.\n\n"}}
{"actor":{"display_login":"carsongross"}}