From 754b0edc05ad01cf4873e46e78e14f9096cabc34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sun, 17 May 2026 16:51:31 +0000 Subject: [PATCH] fix: handle linkedom fragment parsing in shared inlineSubCompositions When linkedom parses a fragment like `
...
`, 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 --- packages/core/src/compiler/inlineSubCompositions.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/compiler/inlineSubCompositions.ts b/packages/core/src/compiler/inlineSubCompositions.ts index ce0cdbc28..54096cecb 100644 --- a/packages/core/src/compiler/inlineSubCompositions.ts +++ b/packages/core/src/compiler/inlineSubCompositions.ts @@ -308,7 +308,11 @@ export function inlineSubCompositions( } } else { for (const child of [...contentDoc.querySelectorAll("style, script")]) child.remove(); - hostEl.innerHTML = contentDoc.body?.innerHTML || ""; + // linkedom fragment parsing: when content is `
...
`, + // the div becomes documentElement and body is empty. Fall back to documentElement.outerHTML + // to preserve the composition wrapper. + const bodyHtml = contentDoc.body?.innerHTML || ""; + hostEl.innerHTML = bodyHtml || contentDoc.documentElement?.outerHTML || ""; } hostEl.setAttribute("data-composition-file", src);