Re: [WICG/webcomponents] Need a callback for when children changed or parser finished parsing children (#809)

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