{"action":"created","issue":{"url":"https://api.github.com/repos/l20n/l20n.js/issues/37","labels_url":"https://api.github.com/repos/l20n/l20n.js/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/l20n/l20n.js/issues/37/comments","events_url":"https://api.github.com/repos/l20n/l20n.js/issues/37/events","html_url":"https://github.com/l20n/l20n.js/pull/37","id":88386311,"number":37,"title":"Turn off MutationObserver while translating DOM","user":{"login":"zbraniecki","id":449986,"avatar_url":"https://avatars.githubusercontent.com/u/449986?v=3","gravatar_id":"","url":"https://api.github.com/users/zbraniecki","html_url":"https://github.com/zbraniecki","followers_url":"https://api.github.com/users/zbraniecki/followers","following_url":"https://api.github.com/users/zbraniecki/following{/other_user}","gists_url":"https://api.github.com/users/zbraniecki/gists{/gist_id}","starred_url":"https://api.github.com/users/zbraniecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbraniecki/subscriptions","organizations_url":"https://api.github.com/users/zbraniecki/orgs","repos_url":"https://api.github.com/users/zbraniecki/repos","events_url":"https://api.github.com/users/zbraniecki/events{/privacy}","received_events_url":"https://api.github.com/users/zbraniecki/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-15T10:39:15Z","updated_at":"2015-06-15T14:17:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/l20n/l20n.js/pulls/37","html_url":"https://github.com/l20n/l20n.js/pull/37","diff_url":"https://github.com/l20n/l20n.js/pull/37.diff","patch_url":"https://github.com/l20n/l20n.js/pull/37.patch"},"body":"Didn't measure perf/mem on this yet"},"comment":{"url":"https://api.github.com/repos/l20n/l20n.js/issues/comments/112085297","html_url":"https://github.com/l20n/l20n.js/pull/37#issuecomment-112085297","issue_url":"https://api.github.com/repos/l20n/l20n.js/issues/37","id":112085297,"user":{"login":"stasm","id":265818,"avatar_url":"https://avatars.githubusercontent.com/u/265818?v=3","gravatar_id":"","url":"https://api.github.com/users/stasm","html_url":"https://github.com/stasm","followers_url":"https://api.github.com/users/stasm/followers","following_url":"https://api.github.com/users/stasm/following{/other_user}","gists_url":"https://api.github.com/users/stasm/gists{/gist_id}","starred_url":"https://api.github.com/users/stasm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stasm/subscriptions","organizations_url":"https://api.github.com/users/stasm/orgs","repos_url":"https://api.github.com/users/stasm/repos","events_url":"https://api.github.com/users/stasm/events{/privacy}","received_events_url":"https://api.github.com/users/stasm/received_events","type":"User","site_admin":false},"created_at":"2015-06-15T14:17:52Z","updated_at":"2015-06-15T14:17:52Z","body":"It would be interesting to see if this improves perf.  If it does, we'd know that we're paying for the many disconnects of the mutation observer.  And if we do, I'm afraid that we'll need to look for saving somewhere else.\r\n\r\nI tried a similar approach as well.  I tried disconnecting in `onMutations` and then waiting for all promises returned by `translate*` methods there and reconnecting.  I realized however that this wouldn't be a valid approach.  Please correct me if I misunderstand:\r\n\r\nEvent loop pass 1:\r\n\r\n - a mutation happens and `onMutations` is called,\r\n - in it, or in `translateElement`, the observer is disconnected,\r\n - `translateElement` asynchronously asks the `ctx` for translation.\r\n \r\nEvent loop pass 2:\r\n\r\n - developer inserts a new element into the DOM,\r\n - the observer is disconnected; the new element is not translated.\r\n\r\nEvent loop pass 3:\r\n\r\n - the `ctx` returns the translations and resolves the `translateElement` promise,\r\n - the translation is applied,\r\n - the observer is re-connected.\r\n\r\nThe thing is, we can't globally disconnect and re-connect the observer if there's any async operation happening in between.  We need to pass the `view` down to the last async function call and disconnect and re-connect it synchronously."}}