A first render can look completely correct while the second render is blank, even though the JavaScript contains no syntax error and every DOM call returns normally. The common trap is not “the fragment stopped working.” It is ownership. A populated DocumentFragment is a temporary parent for real child nodes. When that fragment is inserted, those children are transferred into the destination. The fragment object still exists, but its previous children no longer belong to it. Reusing that same now-empty contents object therefore does not replay the first batch. Under appendChild(), it contributes nothing; under replaceChildren(), that emptiness can be more destructive because replacement first removes the destination’s existing children and then has no fragment children to add. The latter conclusion is a direct algorithmic inference from the DOM Standard’s replacement and insertion steps, not a special “empty-fragment” rule.
This playbook treats that failure as an ownership investigation. We will keep a three-record model (R1/One, R2/Two, R3/Three) independent from the DOM, track exact content and node identity through ten fresh cases, and distinguish moving existing nodes from copying current nodes, reconstructing new nodes from retained data, and trying to copy a source that has already become empty. The two supported repeat-render repairs are correspondingly explicit: build fresh nodes from retained source data, or preserve an intact HTMLTemplateElement.content blueprint and document.importNode(..., true) a new deep copy for every render. The scope stays deliberately narrow: one owned local HTML document, passive ul/li nodes, native DOM methods, and no event, observer, framework, layout, or application-state claims. Specifically excluded are event handlers, cloning listener bindings, event delegation, MutationObserver delivery, live-HTMLCollection removal loops, custom elements, shadow DOM, focus or selection preservation, form state, scripts inserted as content, cross-document application behavior, framework reconciliation, layout, and performance claims. A local DOM reconstruction is not a transaction and does not establish restoration of arbitrary application state.
Define what the second render must contain
Before touching the DOM, define the render contract independently of any observed tree. In this fixture the authoritative business source is an immutable array of exactly three records, in exactly this order: { key: "R1", text: "One" }, { key: "R2", text: "Two" }, and { key: "R3", text: "Three" }. Each rendered li gets data-key from the record key and textContent from the record text. The two owned destinations are ul elements named left and right; repeated business keys across those separate lists are intentional, while document id attributes are not used.
That contract matters because “render again” is not the same operation as “move the same nodes somewhere else.” If the requirement is one one-time transfer, moving existing nodes is correct. If both left and right must simultaneously contain R1/R2/R3, the caller needs two independent node populations. A single node object cannot have both parents at once, and a DocumentFragment does not preserve a hidden replay log after insertion. The experiment therefore asks two questions separately: what content must each target contain, and which source is supposed to remain authoritative after a render?
The retained record array answers the second question for the model-driven repair. The intact template answers it for the template-driven repair. The staging fragment itself does not answer it once its children have moved. Intermediate developers who want prerequisite context on element creation, DOM manipulation, and JavaScript can use Refonte Learning’s frontend HTML and JavaScript foundations; this article assumes those basics and focuses only on repeat-render ownership.
Verify what fragment insertion moves
The normative starting point is the WHATWG DOM Standard, a Living Standard updated 2026-11-25 and accessed 2026-12-03. In the insertion algorithm, when the node being inserted is a DocumentFragment, the insertion nodes are the fragment’s children. Before those nodes are inserted into the new parent, the algorithm removes them from the fragment. If the fragment has no children, the insertion-node list has size zero and insertion returns without adding anything.
That is the core of the “DocumentFragment empty after appendChild” diagnosis: the child nodes are not copied out while remaining children of the fragment. They are the same node objects, and ownership changes. MDN’s Node.appendChild() reference, accessed 2026-12-03, states the same practical result in readable API terms: when the child is a DocumentFragment, its contents are moved into the target, and the return value is the now-emptied fragment. It also notes that appending an already existing node moves that node from its current position.
Two references must therefore stay conceptually separate. A JavaScript variable can still point to the same fragment object after insertion, so returned === fragment can be true. But that object reference is not evidence that the fragment still owns R1, R2, and R3. The ownership evidence is fragment.childNodes.length, the destination’s exact child population, retained node-reference equality, and each node’s current parentNode.
This is also why the fragment should not be described as permanently unusable. Its previous contents have moved; the object remains a valid DocumentFragment. Code may deliberately append newly constructed nodes back into that same object and insert it again. F05 will prove that valid refill workflow. What fails is the assumption that earlier children regenerate automatically merely because the fragment variable is still reachable.
Create the source model and two controlled targets
The fixture below is one self-contained local HTML document. Every F01–F10 case calls the same makeCase() factory, so no case inherits state from another. The source model is frozen separately from the DOM. The expected evidence manifest is literal data written before any case observations are produced; the checker never derives expected rows by reading the observed tree back into “expected” values. Template content is built programmatically, not written with line-broken HTML inside <template>, so incidental whitespace text nodes cannot complicate the child population.
Save this as documentfragment-reuse-fixture.html and open it directly in a browser. No network request, package, framework, or server is required. The page runs once on load and writes a JSON report into <pre id="report">. If you execute it, preserve that report and the browser identity it records; until then, every case in this article remains EXPECTED / NOT EXECUTED. A thrown assertion, an incomplete case inventory, or a checker failure yields HOLD, not a guessed pass.
<!doctype html>
<meta charset="utf-8">
<title>DocumentFragment ownership fixture</title>
<h1>DocumentFragment ownership fixture</h1>
<div id="cases"></div>
<pre id="report"></pre>
<script>
"use strict";
const SOURCE_GENERATION = "MODEL-R123-v1";
const SOURCE = Object.freeze([
Object.freeze({ key: "R1", text: "One" }),
Object.freeze({ key: "R2", text: "Two" }),
Object.freeze({ key: "R3", text: "Three" })
]);
const RECORDS = [
{ key: "R1", text: "One" },
{ key: "R2", text: "Two" },
{ key: "R3", text: "Three" }
];
const EMPTY = [];
function same(a, b) {
return JSON.stringify(a) === JSON.stringify(b);
}
function check(condition, message) {
if (!condition) throw new Error(message);
}
function keyText(parent) {
return [...parent.children].map(li => ({ key: li.dataset.key, text: li.textContent }));
}
function tokens(parent) {
return [...parent.children].map(li => li.dataset.testNode);
}
function buildLi(record, token) {
const li = document.createElement("li");
li.dataset.key = record.key;
li.dataset.testNode = token;
li.textContent = record.text;
return li;
}
function buildFragment(prefix) {
const fragment = document.createDocumentFragment();
SOURCE.forEach((record, index) => fragment.appendChild(buildLi(record, ${prefix}-${index + 1})));
return fragment;
}
function makeTemplate(prefix) {
const template = document.createElement("template");
SOURCE.forEach((record, index) => template.content.appendChild(buildLi(record, ${prefix}-${index + 1})));
return template;
}
function retag(parent, prefix) {
[...parent.children].forEach((node, index) => { node.dataset.testNode = ${prefix}-${index + 1}; });
}
function makeCase(id) {
const wrap = document.createElement("section");
wrap.dataset.case = id;
const left = document.createElement("ul");
const right = document.createElement("ul");
left.dataset.target = "left";
right.dataset.target = "right";
wrap.append(left, right);
document.querySelector("#cases").appendChild(wrap);
return { id, wrap, left, right };
}
function rowBase(id) {
return {
id,
sourceGeneration: SOURCE_GENERATION,
expectedLabel: "EXPECTED / RUN WHEN OPENED",
sourceBefore: null,
sourceAfter: null,
left: null,
right: null,
leftTokens: null,
rightTokens: null,
identity: {}
};
}
function finalize(row, state, sourceNode) {
row.sourceAfter = sourceNode ? keyText(sourceNode) : row.sourceAfter;
row.left = keyText(state.left);
row.right = keyText(state.right);
row.leftTokens = tokens(state.left);
row.rightTokens = tokens(state.right);
return row;
}
// Literal oracle: not generated from observed DOM.
const MANIFEST = Object.freeze({
F01: { sourceBefore: RECORDS, sourceAfter: RECORDS, left: EMPTY, right: EMPTY,
identity: { originalsStillInFragment: true } },
F02: { sourceBefore: RECORDS, sourceAfter: EMPTY, left: RECORDS, right: EMPTY,
identity: { returnIsFragment: true, leftIsOriginals: true } },
F03: { sourceBefore: RECORDS, sourceAfter: EMPTY, left: RECORDS, right: EMPTY,
identity: { leftStillOriginals: true } },
F04: { sourceBefore: EMPTY, sourceAfter: EMPTY, left: RECORDS, right: EMPTY,
identity: { removedRightDetached: true, leftUnchanged: true } },
F05: { sourceBefore: EMPTY, sourceAfter: EMPTY, left: RECORDS, right: RECORDS,
identity: { leftOriginalsUnchanged: true, leftRightDistinct: true } },
F06: { sourceBefore: RECORDS, sourceAfter: EMPTY, left: RECORDS, right: EMPTY,
identity: { templateDrained: true } },
F07: { sourceBefore: RECORDS, sourceAfter: RECORDS, left: RECORDS, right: RECORDS,
identity: { templatePreserved: true, leftRightDistinct: true, copiesDistinctFromTemplate: true } },
F08: { sourceBefore: EMPTY, sourceAfter: EMPTY, left: RECORDS, right: EMPTY,
identity: { clonedEmpty: true, importedEmpty: true } },
F09: { sourceBefore: EMPTY, sourceAfter: EMPTY, left: RECORDS, right: RECORDS,
identity: { leftUnchanged: true, recoveredNodesAreNew: true } },
F10: { sourceBefore: EMPTY, sourceAfter: EMPTY,
left: [{ key: "R1", text: "One" }, { key: "R3", text: "Three" }],
right: [{ key: "R2", text: "Two" }],
identity: { movedR2SameObject: true, r2ParentIsRight: true } }
});
function assertManifestRow(row) {
const expected = MANIFEST[row.id];
check(expected, ${row.id}: missing manifest);
check(row.sourceGeneration === SOURCE_GENERATION, ${row.id}: wrong source generation);
check(same(row.sourceBefore, expected.sourceBefore), ${row.id}: sourceBefore mismatch);
check(same(row.sourceAfter, expected.sourceAfter), ${row.id}: sourceAfter mismatch);
check(same(row.left, expected.left), ${row.id}: left mismatch);
check(same(row.right, expected.right), ${row.id}: right mismatch);
for (const [name, value] of Object.entries(expected.identity)) {
check(row.identity[name] === value, ${row.id}: identity ${name} mismatch);
}
}
function runF01() {
const state = makeCase("F01"), row = rowBase("F01");
const fragment = buildFragment("F01-original");
const originals = [...fragment.children];
row.sourceBefore = keyText(fragment).map(x => ({ ...x }));
row.identity.originalsStillInFragment = originals.every(node => node.parentNode === fragment);
return finalize(row, state, fragment);
}
function runF02() {
const state = makeCase("F02"), row = rowBase("F02");
const fragment = buildFragment("F02-original");
const originals = [...fragment.children];
row.sourceBefore = keyText(fragment).map(x => ({ ...x }));
const returnValue = state.left.appendChild(fragment);
row.identity.returnIsFragment = returnValue === fragment;
row.identity.leftIsOriginals = [...state.left.children].every((node, i) => node === originals[i]);
return finalize(row, state, fragment);
}
function runF03() {
const state = makeCase("F03"), row = rowBase("F03");
const fragment = buildFragment("F03-original");
const originals = [...fragment.children];
row.sourceBefore = keyText(fragment).map(x => ({ ...x }));
state.left.appendChild(fragment); // explicit first-render precondition
state.right.appendChild(fragment); // same object, now empty
row.identity.leftStillOriginals = [...state.left.children].every((node, i) => node === originals[i]);
return finalize(row, state, fragment);
}
function runF04() {
const state = makeCase("F04"), row = rowBase("F04");
const emptyFragment = buildFragment("F04-left-original");
state.left.appendChild(emptyFragment); // consumes fragment; left now owns R1/R2/R3
const leftRefs = [...state.left.children];
state.right.appendChild(buildFragment("F04-right-old"));
const removedRight = [...state.right.children];
row.sourceBefore = keyText(emptyFragment).map(x => ({ ...x }));
state.right.replaceChildren(emptyFragment);
row.identity.removedRightDetached = removedRight.every(node => node.parentNode === null);
row.identity.leftUnchanged = [...state.left.children].every((node, i) => node === leftRefs[i]);
return finalize(row, state, emptyFragment);
}
function runF05() {
const state = makeCase("F05"), row = rowBase("F05");
const fragment = buildFragment("F05-left-original");
state.left.appendChild(fragment);
const leftRefs = [...state.left.children];
row.sourceBefore = keyText(fragment).map(x => ({ ...x }));
SOURCE.forEach((record, i) => fragment.appendChild(buildLi(record, F05-refill-${i + 1})));
state.right.appendChild(fragment);
row.identity.leftOriginalsUnchanged = [...state.left.children].every((node, i) => node === leftRefs[i]);
row.identity.leftRightDistinct = [...state.right.children].every((node, i) => node !== leftRefs[i]);
return finalize(row, state, fragment);
}
function runF06() {
const state = makeCase("F06"), row = rowBase("F06");
const template = makeTemplate("F06-template");
row.sourceBefore = keyText(template.content).map(x => ({ ...x }));
state.left.appendChild(template.content);
check(template.content.childNodes.length === 0, "F06: template should be drained after first direct insertion");
state.right.appendChild(template.content);
row.identity.templateDrained = template.content.childNodes.length === 0;
return finalize(row, state, template.content);
}
function runF07() {
const state = makeCase("F07"), row = rowBase("F07");
const template = makeTemplate("F07-template");
const templateRefs = [...template.content.children];
row.sourceBefore = keyText(template.content).map(x => ({ ...x }));
const leftCopy = document.importNode(template.content, true);
const rightCopy = document.importNode(template.content, true);
retag(leftCopy, "F07-left-copy");
retag(rightCopy, "F07-right-copy");
state.left.appendChild(leftCopy);
state.right.appendChild(rightCopy);
row.identity.templatePreserved = templateRefs.every((node, i) => template.content.children[i] === node);
row.identity.leftRightDistinct = [...state.left.children].every((node, i) => node !== state.right.children[i]);
row.identity.copiesDistinctFromTemplate = [...state.left.children, ...state.right.children]
.every(node => !templateRefs.includes(node));
return finalize(row, state, template.content);
}
function runF08() {
const state = makeCase("F08"), row = rowBase("F08");
const fragment = buildFragment("F08-original");
state.left.appendChild(fragment);
row.sourceBefore = keyText(fragment).map(x => ({ ...x }));
const clonedEmpty = fragment.cloneNode(true);
const importedEmpty = document.importNode(fragment, true);
row.identity.clonedEmpty = clonedEmpty.childNodes.length === 0;
row.identity.importedEmpty = importedEmpty.childNodes.length === 0;
state.right.append(clonedEmpty, importedEmpty);
return finalize(row, state, fragment);
}
function runF09() {
const state = makeCase("F09"), row = rowBase("F09");
const fragment = buildFragment("F09-left-original");
state.left.appendChild(fragment);
const leftRefs = [...state.left.children];
row.sourceBefore = keyText(fragment).map(x => ({ ...x }));
state.right.appendChild(fragment); // failed empty second render
check(state.right.children.length === 0, "F09: failed-render precondition did not hold");
const rebuilt = buildFragment("F09-rebuilt");
state.right.replaceChildren(rebuilt);
row.identity.leftUnchanged = [...state.left.children].every((node, i) => node === leftRefs[i]);
row.identity.recoveredNodesAreNew = [...state.right.children].every((node, i) => node !== leftRefs[i]);
return finalize(row, state, fragment);
}
function runF10() {
const state = makeCase("F10"), row = rowBase("F10");
const fragment = buildFragment("F10-original");
state.left.appendChild(fragment);
const r2 = state.left.children[1];
row.sourceBefore = keyText(fragment).map(x => ({ ...x }));
state.right.appendChild(r2);
row.identity.movedR2SameObject = state.right.firstElementChild === r2;
row.identity.r2ParentIsRight = r2.parentNode === state.right;
return finalize(row, state, fragment);
}
function verifyEvidencePackage(rows) {
const ids = rows.map(row => row.id);
const required = Object.keys(MANIFEST);
check(same(ids, required), inventory mismatch: ${JSON.stringify(ids)});
rows.forEach(assertManifestRow);
return true;
}
const runners = [runF01, runF02, runF03, runF04, runF05, runF06, runF07, runF08, runF09, runF10];
const report = {
fixture: "DocumentFragment child ownership",
sourceGeneration: SOURCE_GENERATION,
executedAt: new Date().toISOString(),
browserIdentity: navigator.userAgent,
status: "HOLD",
cases: [],
checkerNegatives: {}
};
try {
for (const run of runners) {
const row = run();
assertManifestRow(row);
report.cases.push(row);
}
verifyEvidencePackage(report.cases);
const missingCase = JSON.parse(JSON.stringify(report.cases));
missingCase.pop();
try { verifyEvidencePackage(missingCase); report.checkerNegatives.missingCaseRejected = false; }
catch { report.checkerNegatives.missingCaseRejected = true; }
const wrongGeneration = JSON.parse(JSON.stringify(report.cases));
wrongGeneration.find(row => row.id === "F07").sourceGeneration = "MODEL-WRONG";
try { verifyEvidencePackage(wrongGeneration); report.checkerNegatives.wrongGenerationRejected = false; }
catch { report.checkerNegatives.wrongGenerationRejected = true; }
check(report.checkerNegatives.missingCaseRejected, "negative control: missing case was accepted");
check(report.checkerNegatives.wrongGenerationRejected, "negative control: wrong generation was accepted");
report.status = "PASS_EXPECTATIONS_IF_EXECUTED";
} catch (error) {
report.status = "HOLD";
report.failure = { name: error.name, message: error.message };
}
document.querySelector("#report").textContent = JSON.stringify(report, null, 2);
</script>Snapshot primitive content before DOM mutation
The fixture takes sourceBefore by mapping each relevant parent into ordinary {key, text} objects before the mutation being studied. That primitive copy is a historical record. By contrast, saving fragment.childNodes would save a live NodeList; inspecting it after insertion would show the fragment’s current empty state, not a frozen picture of what it used to contain. Likewise, a devtools-expanded native node object can reveal later state when inspected, so it is not a substitute for an authored before-snapshot.
Identity is a different dimension and therefore stays in memory as actual node references for strict === checks. The report serializes meaningful Boolean outcomes such as leftIsOriginals, plus stable test-only data-test-node tokens for each observed list. A native Node serialized by itself is not useful proof of object identity. The acceptance oracle also records exact key/text/order arrays rather than counts alone: three wrong records still have a count of three.
For a manual review, start with the source snapshot rather than the rendered lists. Confirm SOURCE still has three frozen records and that the literal manifest spells those same records independently. Then inspect a case's sourceBefore, sourceAfter, left, and right arrays before looking at its identity flags. Only after content is reconciled should the reviewer use the Boolean identity witnesses to decide whether the operation moved originals or produced new nodes. This order prevents a correct-looking identity check from obscuring wrong data, and it prevents correct text from obscuring an unintended move. The fixture deliberately gives both dimensions equal weight.
Trace the first append and its returned fragment
F01 establishes the uncontested starting state. A fresh fragment contains three li nodes representing R1/One, R2/Two, and R3/Three; left and right are empty; and the code retains references to those three exact nodes. Its expected source snapshot is [R1, R2, R3], and each retained node’s parent is the fragment. No transfer has happened yet. EXPECTED / NOT EXECUTED.
F02 starts fresh rather than depending on F01. It builds another three-node fragment, retains those original node references, and calls left.appendChild(fragment). Under the DOM insertion algorithm, the fragment’s children become the insertion nodes, are removed from the fragment, and are inserted into left. The expected postcondition is therefore an empty fragment and a left list whose exact ordered content is R1/One, R2/Two, R3/Three.
The return check is intentionally narrow: returnValue === fragment must be true. MDN documents that appendChild() returns the emptied DocumentFragment when a fragment is supplied. That return does not provide a new container around the inserted children. It is the same JavaScript object that was passed in, now with zero children.
This distinction resolves a common debugging illusion. Seeing a non-null return value can tempt a caller to treat the result as reusable rendered content. The fixture instead asks what the returned object owns after the call. The expected answer is nothing: fragment.childNodes.length === 0. Meanwhile left owns the original nodes. Successful insertion and source depletion are not contradictory observations; they are two sides of the same transfer.
Retain node identity after insertion
Content equality alone cannot prove whether F02 moved or copied nodes. The fixture therefore compares left.children[0], [1], and [2] with the three references retained before insertion. Each comparison is expected to be strictly equal, and each node’s parentNode is expected to be left. EXPECTED / NOT EXECUTED.
That assertion separates “these nodes display the same strings” from “these are the same node objects.” A copied R1 node could have the same data-key and textContent while failing strict identity. Here, the movement interpretation requires both exact content and preserved object identity. Nothing about event bindings, interaction behavior, focus, selection, or form state is being tested; those topics are explicitly outside this passive-list fixture.
Compare an empty append with an empty replacement
F03 isolates the silent second-render failure. In a fresh case, the setup creates a populated fragment, retains its three node references, and performs the first insertion into left. That explicit precondition consumes the fragment exactly as F02 did. The case then calls right.appendChild(fragment) using the same fragment object. Because its current child list is empty, the DOM insertion algorithm has zero insertion nodes, so right receives nothing. left remains R1/One, R2/Two, R3/Three, and those children are still the retained original objects. EXPECTED / NOT EXECUTED. The second append does not replay, clone, or reconstruct the earlier contents.
F04 makes the more dangerous contrast. Its fresh setup first consumes a three-node fragment into left, leaving that fragment empty. It independently populates right with three other nodes representing the same records and retains references to those right-side nodes. Then it calls right.replaceChildren(emptyFragment).
The precise empty-destination outcome is a direct algorithmic inference from the DOM Standard. replaceChildren() first converts its arguments to a node and invokes the “replace all” algorithm. For a DocumentFragment, the prospective added nodes are its current children. “Replace all” removes all existing children of the destination and, if a replacement node is present, invokes insertion. Here the replacement node exists but contributes zero children, because the fragment is empty. The destination’s old children are therefore removed and no new child is inserted.
The upstream Web Platform Tests file ParentNode-replaceChildren.html, inspected on 2026-12-03 at pinned snapshot e3cad70090774540f1e8ee0137b3d1310a86dd8b, corroborates the surrounding replacement semantics: it checks clearing existing children, replacing children, preserving insertion order, and moving nodes for both Element and DocumentFragment parents. It does not contain a specifically named replaceChildren(emptyFragment) test, so it is test-design evidence rather than the normative source for this exact inference.
F04 expects right to become empty, every retained former right child to have parentNode === null, and left to remain unchanged. EXPECTED / NOT EXECUTED. This is materially different from F03: an empty append contributes nothing while preserving existing target children; an empty replacement can clear the target. Neither method’s mere completion is content-success evidence.
Operationally, that means a renderer should choose appendChild() versus replaceChildren() from the destination contract, not as interchangeable ways to “put the fragment there.” If the target must retain existing children when the incoming batch is empty, replacement is the wrong operation. If the target must exactly mirror a newly generated batch, replacement can be appropriate, but the caller must prove that the incoming source is populated first. In this fixture the safe precondition is an exact R1/R2/R3 snapshot from an authoritative model or intact template. An empty staging fragment should be treated as meaningful current state, not as a promise that old content can be replayed.
Preserve template content across renders
The WHATWG HTML Standard source used here is the Living Standard updated 2026-12-02 and accessed 2026-12-03. It defines template.content as the template element’s associated DocumentFragment; the nodes represented by template content are children of that fragment, not ordinary children of the <template> element itself. The same standard’s examples copy template contents before insertion rather than consuming the blueprint directly.
F06 deliberately violates that ownership policy. A fresh template is created programmatically with exactly three passive li children inside template.content. The before-snapshot is R1/One, R2/Two, R3/Three. The case then calls left.appendChild(template.content) directly. Because content is a DocumentFragment, its actual children transfer into left, leaving the associated fragment empty. A later right.appendChild(template.content) receives no nodes. The expected result is a correct left, an empty right, and an empty template source after the first insertion. EXPECTED / NOT EXECUTED.
The failure is therefore not that templates “only work once.” The failure is that this caller treated the blueprint fragment itself as disposable staging content. If the application needs repeatable template content, the source policy must preserve that associated fragment and insert a fresh copy instead.
Readers investigating a separate problem in which cloned nodes lack JavaScript interaction behavior should use the article on event bindings after cloning DOM nodes. This experiment intentionally excludes handlers, listener bindings, delegation, and interaction counters; structural repeatability is the only question here.
Keep a separate intact blueprint
A template reference such as const template = ... proves only that the HTMLTemplateElement object remains reachable. It does not prove that template.content still owns any children. F06 demonstrates the distinction. A reusable-source contract should assert the template’s exact key/text/order snapshot immediately before and immediately after every intended render.
For this three-record fixture, “intact” means the source remains R1/One, R2/Two, R3/Three in that order and the original template child references remain children of template.content. If a render changes that source population, the source owner should treat the render path as destructive unless that consumption was explicitly intended. Keeping the blueprint separate makes the next render mechanically possible without depending on historical nodes that already moved elsewhere.
Import a fresh deep copy for each destination
F07 implements the template repair explicitly. It creates a fresh template whose associated content fragment owns the three source li nodes, retains references to those template children, and never inserts template.content itself. Instead, each destination gets its own call:
const leftBatch = document.importNode(template.content, true);
left.appendChild(leftBatch);
const rightBatch = document.importNode(template.content, true);
right.appendChild(rightBatch);The true argument is not decorative. The DOM Standard defines Document.importNode() as returning a copy, with descendants included when the deep option is true. The pinned upstream Document-importNode.html, inspected on 2026-12-03 at the same snapshot e3cad70090774540f1e8ee0137b3d1310a86dd8b, distinguishes omitted/false deep import from true, checks descendant presence, verifies that imported nodes belong to the importing document, and verifies that source-node ownership remains unchanged. Source inspection is not execution evidence for this fixture, but those tests explain why the repair deliberately supplies true and why source preservation is an explicit assertion.
MDN’s Document.importNode() reference, accessed 2026-12-03, likewise describes importNode() as making a copy without removing the original and distinguishes it from adoptNode(), which is a move-oriented operation. MDN also notes that import creates the copy in the calling document’s context, while cloneNode() uses the source node’s document context; HTMLTemplateElement.content has a separate owner document. For this owned local document and ordinary passive li nodes, that makes document.importNode(template.content, true) an explicit and readable choice. The article does not generalize that choice into universal equivalence among cloning/importing strategies in richer DOM contexts.
After import, the returned fragment is fresh staging content. Inserting that returned fragment drains the copy, not the preserved template source. Calling import again starts from the still-intact blueprint and produces another fresh population.
Check both source preservation and distinct nodes
F07 has three independent acceptance dimensions. First, left and right must each exactly equal the record oracle R1/One, R2/Two, R3/Three. Second, template.content must still contain its original three records and the same original template child objects after both renders. Third, corresponding children in left and right must be distinct node objects, and both sets must be distinct from the template children. EXPECTED / NOT EXECUTED.
A count of three proves none of those facts by itself. Two targets could each contain three wrong records; a target could accidentally contain the source nodes rather than copies; or the destinations could be correct while the blueprint was consumed, leaving the next render broken. Repeat-render validation needs destination correctness, source preservation, and identity separation as separate assertions.
Refill a fragment object deliberately
F05 exists to prevent an overcorrection: a consumed DocumentFragment object is not poisoned. Its child list is empty, but code can deliberately give it new children. The case first constructs a fragment from the retained source model and appends it to left, consuming the first three node objects. It retains references to those left nodes. At that point fragment.childNodes.length is zero.
The case then loops over the retained immutable model and constructs new li nodes, appending them into the same fragment object. That refill changes the fragment’s current ownership state from empty to three new children. Appending the refilled fragment into right transfers those new children there, draining the fragment again. The expected final state is that both destinations contain R1/One, R2/Two, R3/Three; every original left node is unchanged; and each corresponding right node is a different object. EXPECTED / NOT EXECUTED.
This is the clean answer to the phrase “DocumentFragment reuse.” Reusing the fragment object can be valid when the caller intentionally refills it from an authoritative source. Reusing its old contents is impossible unless those nodes are still owned by it, which they are not after insertion. No automatic regeneration occurs.
There are therefore two reasonable staging-object policies in this narrow fixture. A factory can create a new fragment for each render, or code can retain one empty staging fragment and deliberately refill it with freshly constructed nodes each time. The important ownership rule is the same: the source model, not the drained staging object, is authoritative. This playbook makes no performance claim between those choices; the decision is about clarity and ownership, not speed.
Rebuild missing content from the authoritative model
F08 and F09 separate two operations that are easy to blur together during incident recovery: copying a current DOM source and reconstructing content from retained non-DOM data.
F08 begins with a populated fragment and explicitly consumes it into left. The fragment is now empty. The case then performs both negative variants: fragment.cloneNode(true) and document.importNode(fragment, true). Both copy methods operate on the fragment’s current tree. Because the current fragment has no children, both new fragments are also empty. Inserting those empty copies into right produces no records. EXPECTED / NOT EXECUTED. The DOM cloning/importing contracts provide copies of current nodes; neither API is a history mechanism. The DOM Standard defines deep cloning/import in terms of descendants that exist at the time of copying, and the WPT import source explicitly distinguishes deep descendants without suggesting restoration of removed descendants.
F09 starts fresh and intentionally reproduces the user-visible failure: the initial fragment is inserted into left, then the same empty fragment is appended to right, leaving right blank. Recovery does not copy that consumed source. Instead it calls the node factory against the retained immutable SOURCE records, producing a new three-node fragment, then uses right.replaceChildren(rebuilt). The expected postcondition is exact R1/R2/R3 content in both destinations, with new right node identities and the original left objects untouched. EXPECTED / NOT EXECUTED.
That is a scoped DOM reconstruction, not a transaction rollback. It can recreate the passive list content because the source model retains the fields needed to do so. It does not claim to restore listeners, focus, selection, form values, scripts, arbitrary component state, or anything else excluded from this experiment.
A practical recovery sequence is therefore deterministic. Freeze further writes to the owned targets for the duration of the diagnosis; capture primitive snapshots of the current lists; identify whether a retained model or intact template still exists; reproduce the failed target only in a fresh case; regenerate a new batch from the surviving authority; replace the failed target; and then verify exact content, order, distinct identity where required, and source preservation. If no authority survives, stop at HOLD rather than reconstructing from assumptions about what “must have been there.” That boundary is important because DOM reconstruction can only be as complete as the retained source describes.
A nearby Refonte article covers preserving MutationObserver records at teardown, but that is a different queue-preservation problem. This fixture uses no MutationObserver; its evidence is immediate child content, parent relationships, and retained references.
Copying an empty source cannot recover its history
The F08 negative control should remain visible in the recovery playbook because it rules out a seductive false fix: “deep-clone it this time.” Deepness controls whether current descendants are included. It cannot manufacture descendants that were already transferred elsewhere. The same applies to deep import of an already empty fragment.
Recovery therefore needs one of three surviving authorities: retained source data from which new nodes can be constructed, an intact template blueprint from which fresh nodes can be copied, or intentionally retained original nodes that can be moved. The third option is not a way to populate two destinations simultaneously. Reparenting an original node changes its parent and removes it from its former owner. F10 makes that limitation explicit.
Move one existing node as a comparison control
F10 strips the experiment down to a single ordinary node. A fresh fragment containing R1, R2, and R3 is inserted into left, so left initially owns those three exact node objects. The case retains the R2 object from left.children[1] and then calls right.appendChild(r2).
The expected result is exact and intentionally asymmetric: left becomes R1/One followed by R3/Three, while right contains only R2/Two. The object reference in right.firstElementChild is strictly equal to the retained R2 reference, and r2.parentNode === right. EXPECTED / NOT EXECUTED. MDN describes this behavior directly: appending a node that already exists moves it from its current position rather than duplicating it.
This comparison control clarifies the fragment cases because fragment insertion is not a magical multi-copy operation. The fragment temporarily owns a list of actual nodes; insertion transfers those actual nodes into the destination. F02 verifies that all three retain identity after transfer. F10 shows the same ownership principle for one node without a staging fragment in the middle.
The control also sets a useful boundary for repair design. If product behavior means “move this particular instance from left to right,” retaining and reparenting the node is correct. If product behavior means “render R2 independently in both left and right,” moving that one object cannot satisfy the requirement. The application needs a second node instance created from retained data or copied from a preserved blueprint. The fixture stays inside its owned ul elements and does not extrapolate into a survey of other DOM APIs.
Reconcile all ten cases with independent snapshots
No browser execution was performed for this article. The table below is therefore an EXPECTED / NOT EXECUTED manifest, not a captured results table. The normative expectations come from the standards cited above; the WPT files were inspected as upstream conformance-test source, not run here and not treated as browser certification.
Case | Source after relevant operation | left | right | Required identity/ownership witness | Decision |
F01 | R1/R2/R3 | empty | empty | originals still parented by fragment | EXPECTED / NOT EXECUTED baseline |
F02 | empty fragment | R1/R2/R3 | empty | return is same fragment; left children are originals | EXPECTED / NOT EXECUTED one-time move |
F03 | empty fragment | R1/R2/R3 | empty | left originals unchanged | EXPECTED / NOT EXECUTED failing repeat append |
F04 | empty fragment | R1/R2/R3 | empty | removed right children detached; left unchanged | EXPECTED / NOT EXECUTED destructive empty replacement |
F05 | empty after refill transfer | R1/R2/R3 | R1/R2/R3 | destinations contain distinct nodes | EXPECTED / NOT EXECUTED valid deliberate refill |
F06 | empty template content | R1/R2/R3 | empty | template blueprint drained | EXPECTED / NOT EXECUTED failing direct template insertion |
F07 | intact R1/R2/R3 template | R1/R2/R3 | R1/R2/R3 | template preserved; both destination copies distinct | EXPECTED / NOT EXECUTED preferred template repair |
F08 | empty fragment | R1/R2/R3 | empty | deep clone and deep import are both empty | EXPECTED / NOT EXECUTED negative copy control |
F09 | original fragment still empty | R1/R2/R3 | R1/R2/R3 | recovered right nodes are new; left unchanged | EXPECTED / NOT EXECUTED model reconstruction repair |
F10 | empty staging fragment | R1/R3 | R2 | moved R2 is same object and now parented by right | EXPECTED / NOT EXECUTED single-node move control |
The discipline here resembles the broader lesson in DOM dispatch results and application evidence: read an API’s return contract narrowly and validate the application condition independently. That article studies a different API and different failure channels; this fixture only uses the analogy that a method return is not a substitute for the content oracle.
For this problem, the independent oracle is simple enough to be explicit: exact business keys, exact text, exact order, exact source generation, and the identity relationships relevant to each case. That gives QA a reproducible way to distinguish “nothing threw” from “the intended destination population exists and the chosen repeatable source survived.”
When the fixture is eventually executed, keep the reference expectations and the observed report as separate artifacts. Do not overwrite the expected table with browser output. Record the actual browser identity from the page report, preserve the full case array, and mark any divergence as HOLD until it is explained against the standards or isolated as a fixture defect. A local run can add observation evidence; it cannot retroactively turn the inspected WPT source into evidence that those upstream tests were executed in the same browser session.
Reject incomplete or misleading evidence
A reliable repeat-render investigation should reject evidence that is plausible-looking but incomplete. The fixture’s package requires exactly F01 through F10 in order, each associated with MODEL-R123-v1. Each row carries before/after source snapshots where applicable, exact left and right key/text arrays, stable test-only node tokens, and named Boolean identity assertions. verifyEvidencePackage() checks the case inventory against the literal manifest and then checks every row against expectations.
Several weaker approaches are intentionally excluded. A live childNodes collection is not a historical snapshot because its contents reflect later mutations. A count such as children.length === 3 does not prove record identity or order. Serializing a native Node object does not prove in-page reference equality. Reading the observed DOM and using that same read to manufacture “expected” data compares the system with itself and can bless the same defect twice.
The fixture instead uses different evidence forms for different claims. Primitive arrays preserve historical content. Retained references support strict equality and parent checks while the page is alive. Stable data-test-node tokens make the serialized report inspectable without pretending that matching strings prove object identity. The literal manifest supplies the independent target. None of those channels alone replaces the others.
An unexpected value yields HOLD. So does an incomplete execution, a thrown setup assertion, a missing case, or a checker-negative that fails to reject corrupted evidence. A predicted failure witness can still “pass” its diagnostic assertion (for example, F03 correctly proving that right is empty), but that does not authorize the failing rendering strategy. It means the laboratory successfully reproduced the defect condition.
The WPT sources support this evidence mindset without being substituted for local results. ParentNode-replaceChildren.html checks concrete resulting child arrays and node order, while Document-importNode.html checks descendants, owner-document relationships, and preserved source ownership. Those are inspected examples of conformance-test design at the pinned snapshot, not claims that this local fixture was run in any browser.
Detect a missing case and a wrong source generation
The page includes two authored checker negatives, both operating on copies of the completed evidence package. The first deletes one case before calling verifyEvidencePackage(). The checker must reject the shortened inventory. The second changes F07’s sourceGeneration from MODEL-R123-v1 to MODEL-WRONG; the checker must reject that package as well. If either corrupted package is accepted, the overall report remains HOLD.
Those controls matter because evidence can become misleading during manual aggregation even when individual DOM assertions are sound. Review must not silently deduplicate rows, fill a missing case from memory, or “repair” a generation label into what looks plausible. Preserve failed and partial runs as their own evidence. A later clean execution is a new record, not a mutation of the old one.
Choose a rendering policy and assign ownership
The API choice follows from the ownership requirement, not from whether a fragment variable is convenient to keep around. A useful review question is: after this render, what source must still exist so that the next render can be generated independently? The answer should be explicit before code is accepted.
Intended operation | Authoritative source after render | Render action | Repeat-render result | Policy |
One-time move of an existing batch | destination now owns the moved nodes | append populated fragment once | original fragment is empty | valid only when replay is not required |
Reuse one staging fragment object | retained immutable record model | refill fragment with newly built nodes, then insert | source model survives; fragment drains each time | valid deliberate refill |
Repeat from template | intact template.content blueprint | document.importNode(template.content, true) per destination | blueprint survives; copies are independent | supported repair |
Repeat from data | retained immutable record model | build a new fragment/nodes per render | model survives; nodes are independent | supported repair |
Copy consumed staging source | none | clone/import empty fragment | empty copy | reject as recovery |
Required source is missing or evidence incomplete | unknown | do not infer historical content | cannot establish correct replay | HOLD |
For a component-maintenance team, ownership can be assigned plainly. The source owner maintains the immutable records or intact template and prevents accidental consumption. The factory owner converts that source into fresh li nodes or a fresh imported fragment. The destination owner decides whether the operation is append, replacement, or an intentional move. The verification owner checks literal content/order plus the required identity and source-preservation assertions. Those roles can be held by the same person or module; naming them is about responsibility, not organizational structure.
A code-review checklist can stay correspondingly short: identify the reusable authority; show whether the render path moves or copies; prove the source still exists after a successful render when another render is expected; demonstrate independent destination identity when two populations must coexist; and define the behavior of an empty source before choosing replacement. If any answer depends on “the fragment variable is still there,” the ownership analysis is incomplete. The variable proves reachability of the container object, not retention of its former children.
The two preferred repairs in this article are therefore qualified rather than universal. If the source of truth is application data, reconstruct fresh passive nodes from that retained model. If the source of truth is reusable passive markup, keep template.content intact and import a new deep copy for each render. Both satisfy the fixture’s requirement that two destinations can hold complete independent content without consuming the reusable source. The HTML Standard’s template example preserves a source and copies its contents for insertion, and the DOM/import references define the deep-copy behavior used here.
Do not confuse code rollback with DOM rollback. Reverting a line that consumed a fragment does not automatically move already transferred nodes back, restore children already removed by replaceChildren(), or recreate state that was never retained. Recovery needs current evidence plus an authoritative source. A local reconstruction only restores the scoped passive content represented by that source.
The separate concern of event registration cleanup and component lifetime belongs in its own lifecycle review. This fixture deliberately contains no handlers, AbortController, delegation, or listener teardown, so its PASS/HOLD decision says nothing about those responsibilities.
Practice reliable DOM fundamentals with Refonte Learning
The ownership experiment above depends on durable frontend fundamentals: creating semantic HTML nodes, using JavaScript to construct and inspect DOM trees, reasoning about object identity, and validating behavior with small reproducible projects. Refonte Learning’s FrontEnd Developer Program currently lists a four-month period and a dedication of 10–12 hours per week. Its published competencies include HTML5/CSS3, JavaScript ES6+, React, Redux, APIs/AJAX, Git, accessibility, performance optimization, and a capstone; the FAQ also names npm and Visual Studio Code. The page describes practical projects, educational mentoring, and a potential internship, and it lists a Training Certificate and Certificate of Internship after successful completion.
Those confirmed program details are a reason to connect this playbook to broader HTML/JavaScript practice, not evidence that the curriculum teaches this exact DocumentFragment/template-content laboratory. Specialized coverage of this experiment, browser versions taught, and individual mentoring cadence require confirmation. The page also contains an admissions tension that should not be papered over: its requirements block asks for basic programming understanding and says HTML/CSS familiarity is helpful; its admission prerequisite says applicants must be working toward a bachelor’s or higher-level degree; yet its FAQ says prior coding experience is not required. Exact eligibility and reconciliation of these requirements require confirmation. Internship allocation, schedule, and terms also require confirmation; “potential internship” and completion certificates do not guarantee employment or an individual placement.
