{"action":"created","issue":{"url":"https://api.github.com/repos/knockout/knockout/issues/2141","repository_url":"https://api.github.com/repos/knockout/knockout","labels_url":"https://api.github.com/repos/knockout/knockout/issues/2141/labels{/name}","comments_url":"https://api.github.com/repos/knockout/knockout/issues/2141/comments","events_url":"https://api.github.com/repos/knockout/knockout/issues/2141/events","html_url":"https://github.com/knockout/knockout/issues/2141","id":183727225,"number":2141,"title":"ko.utils.domData storage scheme requires explicit cleanup","user":{"login":"mstarets","id":862866,"avatar_url":"https://avatars.githubusercontent.com/u/862866?v=3","gravatar_id":"","url":"https://api.github.com/users/mstarets","html_url":"https://github.com/mstarets","followers_url":"https://api.github.com/users/mstarets/followers","following_url":"https://api.github.com/users/mstarets/following{/other_user}","gists_url":"https://api.github.com/users/mstarets/gists{/gist_id}","starred_url":"https://api.github.com/users/mstarets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstarets/subscriptions","organizations_url":"https://api.github.com/users/mstarets/orgs","repos_url":"https://api.github.com/users/mstarets/repos","events_url":"https://api.github.com/users/mstarets/events{/privacy}","received_events_url":"https://api.github.com/users/mstarets/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-10-18T15:50:09Z","updated_at":"2016-11-04T14:09:18Z","closed_at":null,"body":"This problem has been previously brought up in the rejected Issue #1695. Our case idifferent, however: we have no way of ensuring that the explicit ko.cleanNode() is always invoked for the removed element. \nAlso note that jQuery has switched to storing data on the expando - https://github.com/jquery/jquery/issues/1734. And they had long been advocating for the same data storage solution as Knockout's...\n\nOr use case is as follows:\n1. We rely on custom element support (part of the web component spec) to activate our composite component (see https://developer.mozilla.org/en-US/docs/Web/API/Document/registerElement)\n2. We are using Knockout to manage the composite component's template. \n3. The template will only reference observables stored with the element's properties. No external observables will be used. This means that the custom element should be garbage-collectable when it is removed. \n4. Custom elements are designed to rely on garbage collection for their cleanup, and we cannot require our users to call the explicit cleanup method. \n\nUnfortunately, Knockout's domData maintains references to to all DOM nodes where bindings were applied, so all DOM nodes within the Knockout template remains in memory heap.\n\nHere is a jsFiddle that demonstrates the issue: https://jsfiddle.net/mstarets/4nfsebec/5/. It needs to be run in Chrome (otherwise you will need to include the Custom Element polyfill). After you run the page, click on 'Create Custom Element button, then on 'Remove Custom Element' button. Repeat this sequence 2-3 times. Open Developer Tools, go to the 'Profiles' tab and take a heap snapshot. Note that there are several hundred of HTMLButtonElements that have been leaked. Now uncomment the line calling clearDataForButtons() and repeat the same test. Note that the button elements are no longer leaked.\n"},"comment":{"url":"https://api.github.com/repos/knockout/knockout/issues/comments/258440879","html_url":"https://github.com/knockout/knockout/issues/2141#issuecomment-258440879","issue_url":"https://api.github.com/repos/knockout/knockout/issues/2141","id":258440879,"user":{"login":"brianmhunt","id":135528,"avatar_url":"https://avatars.githubusercontent.com/u/135528?v=3","gravatar_id":"","url":"https://api.github.com/users/brianmhunt","html_url":"https://github.com/brianmhunt","followers_url":"https://api.github.com/users/brianmhunt/followers","following_url":"https://api.github.com/users/brianmhunt/following{/other_user}","gists_url":"https://api.github.com/users/brianmhunt/gists{/gist_id}","starred_url":"https://api.github.com/users/brianmhunt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianmhunt/subscriptions","organizations_url":"https://api.github.com/users/brianmhunt/orgs","repos_url":"https://api.github.com/users/brianmhunt/repos","events_url":"https://api.github.com/users/brianmhunt/events{/privacy}","received_events_url":"https://api.github.com/users/brianmhunt/received_events","type":"User","site_admin":false},"created_at":"2016-11-04T14:09:18Z","updated_at":"2016-11-04T14:09:18Z","body":"If using a WeakMap, the DOM node would be the key.\r\n\r\nThe problem with WeakMap is browser support ... IE < 11."}}
{"actor":{"display_login":"brianmhunt"}}