Skip to content

Write HTML. Render video. Built for agents.

fix: handle linkedom fragment parsing in shared inlineSubCompositions

Miguel Ángel754b0edc05ad
diff --git a/packages/core/src/compiler/inlineSubCompositions.ts b/packages/core/src/compiler/inlineSubCompositions.ts
index ce0cdbc28d..54096cecb4 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 `<div data-composition-id="X">...</div>`,
+ // 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);