MutationObserver#whatwgTPAC 2026
Dublin, Ireland & online
26–30 October 2026
dom#662, wc#809)addedNodes & connectedCallback() run before children exist</s-select> is ready to hydrateWhen the HTML parser sees a start tag, it inserts the element into the DOM immediately before parsing its children. If a network chunk splits inside the element, addedNodes and connectedCallback() see a half-parsed subtree with no signal when the closing tag arrives.
wc#809)dom#1116)html#12200)Four structural (non-text) use cases: (1) compound custom elements like <s-select>, tabs, data tables, or WebGL scenes that index/validate child elements and want to avoid O(N^2) work or false "missing child" errors mid-stream; (2) streaming DOM morphers (idiomorph, Turbo, Marko) that otherwise delete existing live DOM nodes because the incoming subtree isn't finished yet; (3) SSR island hydration that expects the component's full DOM tree; and (4) View Transitions and entry animations on complete subtrees ( plus text/code evaluation like syntax highlighters and math blocks).
DOMContentLoadedsetTimeout / rAFnextSibling ancestor walksToday libraries choose between waiting for DOMContentLoaded (giving up incremental rendering), timers (which break on slow networks), or walking ancestors on every MutationRecord to check for a nextSibling (which costs 100ms+ on large pages and still fails for last-child chains).
#110)<template for> — never enters the DOMMutationObserver only sees inner nodes land in <main>When the parser processes a <template for> patch, it consumes the <template> element itself and streams its content directly into the target region (<?start name="results"> inside <main>). MutationObserver only sees individual child insertions inside <main>—the patch wrapper, its attributes, and its start/end/abort boundaries are completely invisible.
data-turn="3", request IDs)What applications need from <template for> observation (#110 from OpenAI, html#13008): (1) attribution—telling server-streamed patches apart from local client mutations; (2) reading metadata attributes like data-turn="3" off the template; (3) lifecycle hooks for patch start and completion; and (4) error recovery when a stream truncates before </template> or targets a missing marker.
“If we expose a parser-completion hook, developers will rely on it and break imperative DOM creation (
createElement+appendChild).”
MutationObserver is microtask-batched: unifies parser completion & dynamic editsthis in constructor()Why MutationObserver avoids the classic connectedCallback() / parsedCallback() trap: if someone writes const el = document.createElement('s-select'); document.body.append(el); el.append(option);, connectedCallback() fires synchronously on body.append(el) before option is attached. By contrast, a MutationObserver runs at the microtask checkpoint—after both synchronous append() calls have completed—unifying parser completion and dynamic DOM mutations.
</el>addedNodes loop works unchanged; no new record typessubtree: true (<s-option> before <s-select>); interleaving with mid-parse JS editsOption A: instead of introducing a new record shape, tell the MutationObserver to buffer parser-inserted elements until their closing tag is popped from the stack of open elements (and if observing a specific root element, buffer child mutations until that root closes). Pros: standard addedNodes loops work unchanged across single-chunk, multi-chunk, and dynamic appendChild. Trade-offs: on subtree: true, inner elements close and fire before outer ancestors (bottom-up order), and open containers aren't reported to the observer until they close.
isParsing + Completion RecordOption B: keep addedNodes firing on the start tag as today, expose element.isParsing (true while open on the parser stack, false once popped), and emit a completion record only when an element that was still open at the end of an earlier chunk closes in a later chunk. Pros: preserves top-down ordering and lets observers see open containers immediately. Trade-offs: callbacks need two branches to handle same-chunk addedNodes vs. cross-chunk completion.
record.parsedElementsaddedNodes timingaddedNodes loopOption C: attach a parsedElements NodeList to MutationRecord listing elements whose closing tags were popped during that batch (or pair with a Custom Element parsedCallback()). Pros: explicit and doesn't change addedNodes timing. Trade-offs: allocates an extra list and separates parser completion from the addedNodes loop used for imperative DOM insertions.
template: true)templateAttributes — ReadOnlyMap of active <template for> attributes (shared identity per patch)"start" | "update" | "end" | "abort" per chunk, or buffer patch records until </template>For <template for> patches, MutationRecord carries templateAttributes (a shared ReadOnlyMap of the template's attributes) and templateStatus ("start", "update", "end", or "abort" on stream truncation / missing target). This also composes with buffering if an observer wants to receive the patch only when </template> finishes or aborts.
addedNodes until </el>element.isParsing + cross-chunk completion recordrecord.parsedElements list<template for> metadata: templateAttributes + templateStatus<template shadowrootmode="open"> (dom#1287)?Participate: WICG/declarative-partial-updates (parser-mutation-records-explainer.md · #110)
Open the floor for discussion on the three design options for surfacing parse-end (buffering addedNodes vs. isParsing + completion record vs. parsedElements) and <template for> lifecycle metadata.
Explainer: https://github.com/WICG/declarative-partial-updates/blob/main/parser-mutation-records-explainer.md. Overall theme: client-side reflection of server-driven UI—parseEnd is for hydration & subtree readiness, and template is for flow control & error recovery.