Skip to content

Commit 754b0ed

Browse files
miguel-heygenclaude
andcommitted
fix: handle linkedom fragment parsing in shared inlineSubCompositions
When linkedom parses a fragment like `<div data-composition-id="X">... </div>`, the div becomes the documentElement and body is empty. contentDoc.body?.innerHTML returns "" losing the composition wrapper. Fall back to contentDoc.documentElement?.outerHTML when body content is empty, preserving composition IDs for sub-compositions where the host data-composition-id differs from the inner root's. Fixes style-1-prod regression (captions sub-comp has host id "captions-comp" but inner root id "captions"). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 581e7a7 commit 754b0ed

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/core/src/compiler/inlineSubCompositions.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,11 @@ export function inlineSubCompositions(
308308
}
309309
} else {
310310
for (const child of [...contentDoc.querySelectorAll("style, script")]) child.remove();
311-
hostEl.innerHTML = contentDoc.body?.innerHTML || "";
311+
// linkedom fragment parsing: when content is `<div data-composition-id="X">...</div>`,
312+
// the div becomes documentElement and body is empty. Fall back to documentElement.outerHTML
313+
// to preserve the composition wrapper.
314+
const bodyHtml = contentDoc.body?.innerHTML || "";
315+
hostEl.innerHTML = bodyHtml || contentDoc.documentElement?.outerHTML || "";
312316
}
313317

314318
hostEl.setAttribute("data-composition-file", src);

0 commit comments

Comments
 (0)