- From: Joe Pea <notifications@github.com>
- Date: Sat, 02 Feb 2019 13:26:33 -0800
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 2 February 2019 21:26:55 UTC
> nobody said that is the place indeed and you should add the observer within the constructor. Yes, but `connectedCallback` and `disconnectedCallback` seemed like the right way to create it and reciprocally destroy it. It was obvious or intuitive that making an observer in `constructor` would work, while making one in `connectedCallback` wouldn't. So in [the example](https://github.com/w3c/webcomponents/issues/787#issuecomment-459829842) I'm doing it in both `constructor` and `connectedCallback` with conditional checks, so that `disconnectedCallback` can clean it up and if the node is reconnected it can regain the functionality in `connectedCallback` instead of `constructor`. This is all under the assumption that a `MutationObserver` **_should_** be cleaned up by calling its `disconnect()` method. Can we expect things to be garbage collected when the node is not used anymore, without calling `observer.disconnect()`? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/webcomponents/issues/550#issuecomment-460000461
Received on Saturday, 2 February 2019 21:26:55 UTC