- From: silverwind <notifications@github.com>
- Date: Tue, 05 Mar 2024 16:35:05 -0800
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 6 March 2024 00:35:09 UTC
To me it seems to reliably access children in `connectedCallback`, one has to check for both existing children (which is the case when the element is appended to the DOM via `.innerHTML` or similar methods like Vue does it), and for regular DOM content where the children will be available after a `childList` mutation. ```js connectedCallback() { if (this.children.length) // access this.children } else { const observer = new MutationObserver(() => { observer.disconnect(); // access this.children }).observe(this, {childList: true}); } } ``` Honstly, it seems way to much boilerplate for such a simple and common use case. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/issues/809#issuecomment-1979868644 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/issues/809/1979868644@github.com>
Received on Wednesday, 6 March 2024 00:35:09 UTC