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);