Re: [whatwg/dom] Custom element callback/promise for "connected and parsed" (#662)

trusktr left a comment (whatwg/dom#662)

I currently:

- connectedCallback create mutation observer in childList (actually, more specifically, I have a flat tree children observer, which is the true thing that should always be observed, otherwise user composition won't work as they expect)
- then any time (flat) children change I handle the new picture. Ofc that's not as efficient if some later child is added (because parsing) that requires undoing or redoing previous work.

A `connectedParsedCallback` would be nifty to avoid work until parsing is done, but we probably also need a way to know when we get connected without parsing.

For example, if connectedCallback took an argument like isParsing, or elements had a new property, which would be false if the element got connected from parsing, then we would know when to do work.

Two cases:

- do work in connectedCallback (isParsing is false), we don't need to also wait for connectedParsedCallback or similar
- skip connectedCallback (isParsing was true) and instead do work in connectedParsingCallback

If an element is disconnected before parsing finishes, connectedParsedCallback won't be called.

We cannot rely only on something like connectedParsedCallback because an element can be appended with parent.append(el), so we need to know if connected isParsing or not.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/662#issuecomment-5721130801
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/662/5721130801@github.com>

Received on Thursday, 17 September 2026 20:58:42 UTC