Repository navigation
Conversation
Rewrite the expectations so that connectedCallback and disconnectedCallback run after the adoption agency algorithm has finished rather than after each reparenting step. Every callback therefore observes the final tree: the reparented element is reported as connected, and reactions queued by the intermediate removals and insertions are invoked back-to-back in order. See whatwg/html#13215.
|
@whatwg/html-parser |
AI feedbackReviewed at f40f15e. The new algorithm's cross-references resolve, and the Blockers
Suggestions
Nits
|
|
Addressed all comments:
|
AI feedbackReviewed at 1c0d36b. Suggestions
|
|
Updated the PR description to clarify that For the other two points ( |
1c0d36b to
237051a
Compare
The adoption agency algorithm removes and inserts nodes directly without an element queue on the custom element reactions stack. During normal parsing (when the JavaScript execution context stack is empty),
disconnectedCallbackandconnectedCallbackreactions from reparenting the furthest block and its children are enqueued on the backup element queue and only run at the next microtask checkpoint (such as at a following</script>end tag, after any intervening tokens—or the new element for an<a>or<nobr>start tag—have already been parsed). When the parser is driven from script (e.g., viadocument.write()),document.write()'s[CEReactions]extended attribute makes its element queue the current element queue, so those reactions are enqueued there and only run whendocument.write()returns, after a following<script>has already executed.Push a new element queue before running the inner adoption agency algorithm and pop and invoke it once the algorithm finishes, matching how "insert an element at the adjusted insertion location" handles reactions.
Wrapping the algorithm as a whole rather than each DOM operation inside it ensures that:
Tests: web-platform-tests/wpt#64911.
Fixes #13072.
(See WHATWG Working Mode: Changes for more details.)
/parsing.html ( diff )