- From: Keith Cirkel <notifications@github.com>
- Date: Fri, 10 Mar 2023 04:29:05 -0800
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 10 March 2023 12:29:18 UTC
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