Repository navigation
Conversation
Test that the custom element reactions caused by the adoption agency algorithm moving the furthest block, moving it into a clone created by the inner loop, and moving its children into the new formatting element are invoked before the following script element runs, both when parsing the document and from document.write(), and that each reaction observes the tree as it is right after the step that caused it. For whatwg/html#13072.
|
Review-and-fix pass over the current head (b9d9cd8), together with whatwg/html#13215. Questions / follow-ups
FindingsNo changes needed. All four tests trace correctly through the spec change, and each can fail against the previous text: without the per-step queues the reactions would run from a microtask or, for Results: Chrome Canary passes all four. Firefox passes the simple and |
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.
AI feedbackReviewed at 48544ae. In tip-of-tree WebKitTestRunner, the first three subtests pass and the Suggestions
|
…d element grouping
|
Addressed all comments:
|
AI feedbackReviewed at 53651b2. Suggestions
|
|
Fixed in |
Spec PR: whatwg/html#13215 (for whatwg/html#13072).
The adoption agency algorithm reparents nodes, and when they are or contain custom elements, that queues
connectedCallback()anddisconnectedCallback()reactions. Without an element queue around the adoption agency algorithm, those reactions go to the backup element queue during normal parsing (running at the next microtask checkpoint, such as at a</script>end tag after any intervening tokens have been parsed) or todocument.write()'s element queue when parsing from script (running only whendocument.write()returns, after a written<script>has already executed). The spec PR pushes an element queue around the whole algorithm, so the reactions run once it finishes, before later tokens are processed, and every callback observes the final tree produced by the algorithm.The test uses an
x-aaaelement that logs each callback together withisConnected, its parent at that moment, and optional element ID or target-presence checks:<b><p><x-aaa></x-aaa></b>: moving<p>to the common ancestor and moving its children into the new<b>each produce a disconnected/connected pair; all four callbacks run before the script and see<x-aaa>connected inside the new<b>.<b><i><p><x-aaa></x-aaa></b>: the inner loop moves<p>into a clone of<i>that is not yet inserted; the callbacks do not observe that intermediate state and log the same as above.<b><p><x-aaa data-check-id="after"></x-aaa></b><span id="after"></span>: callbacks run right after the adoption agency algorithm finishes, before#afteris parsed.<a><p><x-aaa data-check-id="a2"></x-aaa><a id="a2"></a>: callbacks run during the second<a>start tag before#a2is inserted.<b><p><x-aaa id="first"></x-aaa><x-aaa id="second"></x-aaa></b>: reactions for multiple custom elements in the furthest block are invoked grouped per element (all four of#first's callbacks before#second's).document.write('<b><p><x-aaa></x-aaa></b><script>...</script>'): reactions run before the written<script>, with nothing left over whendocument.write()returns.