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

For my own edification, how would one determine an element is parsed reliably today? I suppose checking `nextSibling` for each mutation until done? Then I guess also `DOMContentLoaded` in case your element is the last in the tree? Something like:

```js
function isPased(el) {
  if (el.nextSibling) return true
  let node = el
  while(node = node.parentNode) if (node.nextSibling) return true
}
const dcl = new Promise(resolve => document.addEventListener('domcontentloaded', resolve))
function whenParsed(el) {
  if (isParsed(el)) return Promise.resolve()
  return new Promise((resolve) => {
    const observer = new MutationObserver(records => {
      if(isParsed(el)) {
        observer.disconnect()
        resolve()
      }
    }).observe(el)
    dcl.then(() => {
      observer.disconnect()
      resolve()
    })
  })
}
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/809#issuecomment-1463736343
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/809/1463736343@github.com>

Received on Friday, 10 March 2023 12:29:18 UTC