mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 12:54:29 +00:00
fix(producer): preserve inner root element when inlining sub-compositions
The producer's inlineSubCompositions was not passing flattenInnerRoot, causing sub-composition inner root elements to be unwrapped during compilation. Scripts using #id selectors (rewritten to [data-hf-authored-id] by the scoping proxy) could not find their DOM root because the authored-id attribute was never set. The core bundler (bundleToSingleHtml) already passed flattenInnerRoot correctly. This aligns the producer's render compilation with the same behavior: clone the inner root, strip timing/composition attrs, replace id with data-hf-authored-id, and mark with data-hf-inner-root.
This commit is contained in:
@@ -559,6 +559,19 @@ function inlineSubCompositions(
|
||||
|
||||
if (!hosts.length) return html;
|
||||
|
||||
const FLATTENED_INNER_ROOT_STRIP_ATTRS = [
|
||||
"data-composition-id",
|
||||
"data-composition-file",
|
||||
"data-start",
|
||||
"data-duration",
|
||||
"data-end",
|
||||
"data-track-index",
|
||||
"data-track",
|
||||
"data-composition-src",
|
||||
"data-hf-authored-duration",
|
||||
"data-hf-authored-end",
|
||||
];
|
||||
|
||||
const result = inlineSubCompositionsShared(
|
||||
document as unknown as Document,
|
||||
hosts as unknown as Element[],
|
||||
@@ -574,6 +587,19 @@ function inlineSubCompositions(
|
||||
return compHtml;
|
||||
},
|
||||
parseHtml: (htmlStr: string) => parseHTML(htmlStr).document as unknown as Document,
|
||||
flattenInnerRoot: (innerRoot: Element): Element => {
|
||||
const prepared = innerRoot.cloneNode(true) as Element;
|
||||
const authoredRootId = prepared.getAttribute("id")?.trim();
|
||||
for (const attrName of FLATTENED_INNER_ROOT_STRIP_ATTRS) {
|
||||
prepared.removeAttribute(attrName);
|
||||
}
|
||||
if (authoredRootId) {
|
||||
prepared.removeAttribute("id");
|
||||
prepared.setAttribute("data-hf-authored-id", authoredRootId);
|
||||
}
|
||||
prepared.setAttribute("data-hf-inner-root", "true");
|
||||
return prepared;
|
||||
},
|
||||
scriptErrorLabel: "[Compiler] Composition script failed",
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user