mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 14:27:26 +00:00
fix: preserve anonymous inlined composition roots
This commit is contained in:
@@ -502,15 +502,12 @@ export async function bundleToSingleHtml(
|
||||
);
|
||||
|
||||
if (innerRoot) {
|
||||
const innerCompId = innerRoot.getAttribute("data-composition-id");
|
||||
const innerW = innerRoot.getAttribute("data-width");
|
||||
const innerH = innerRoot.getAttribute("data-height");
|
||||
if (innerCompId && !hostEl.getAttribute("data-composition-id"))
|
||||
hostEl.setAttribute("data-composition-id", innerCompId);
|
||||
if (innerW && !hostEl.getAttribute("data-width")) hostEl.setAttribute("data-width", innerW);
|
||||
if (innerH && !hostEl.getAttribute("data-height")) hostEl.setAttribute("data-height", innerH);
|
||||
for (const child of [...innerRoot.querySelectorAll("style, script")]) child.remove();
|
||||
hostEl.innerHTML = innerRoot.innerHTML || "";
|
||||
hostEl.innerHTML = compId ? innerRoot.innerHTML || "" : innerRoot.outerHTML || "";
|
||||
} else {
|
||||
for (const child of [...contentDoc.querySelectorAll("style, script")]) child.remove();
|
||||
hostEl.innerHTML = contentDoc.body.innerHTML || "";
|
||||
|
||||
@@ -657,8 +657,8 @@ describe("template-wrapped sub-composition media offsets", () => {
|
||||
const { document } = parseHTML(compiled.html);
|
||||
const host = document.querySelector("#scene-host");
|
||||
|
||||
expect(host?.getAttribute("data-composition-id")).toBe("scene");
|
||||
expect(host?.querySelector(".title")?.textContent).toBe("Scene");
|
||||
expect(host?.getAttribute("data-composition-id")).toBeNull();
|
||||
expect(host?.querySelector('[data-composition-id="scene"] .title')?.textContent).toBe("Scene");
|
||||
expect(compiled.html).toContain('var __hfCompId = "scene";');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -650,16 +650,12 @@ function inlineSubCompositions(
|
||||
);
|
||||
|
||||
if (innerRoot) {
|
||||
const innerCompId = innerRoot.getAttribute("data-composition-id");
|
||||
const innerW = innerRoot.getAttribute("data-width");
|
||||
const innerH = innerRoot.getAttribute("data-height");
|
||||
if (innerCompId && !host.getAttribute("data-composition-id")) {
|
||||
host.setAttribute("data-composition-id", innerCompId);
|
||||
}
|
||||
if (innerW && !host.getAttribute("data-width")) host.setAttribute("data-width", innerW);
|
||||
if (innerH && !host.getAttribute("data-height")) host.setAttribute("data-height", innerH);
|
||||
innerRoot.querySelectorAll("style, script").forEach((el) => el.remove());
|
||||
host.innerHTML = innerRoot.innerHTML || "";
|
||||
host.innerHTML = compId ? innerRoot.innerHTML || "" : innerRoot.outerHTML || "";
|
||||
} else {
|
||||
contentDoc.querySelectorAll("style, script").forEach((el) => el.remove());
|
||||
host.innerHTML = contentDoc.toString();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0cb2f8b9a8be963ecb14e4a18cad63c67fcbffa075d6cf2238e9c5ed6167f3fd
|
||||
size 9143629
|
||||
oid sha256:eebad98e4c4b2243e8b21732b95f46735304d98a209a51ce761d2e30719b378c
|
||||
size 12828773
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d5796cfc1252d4af0778f44fb1d7a7e6e75adb30abde050463d1be6e4184d8e8
|
||||
size 12421404
|
||||
oid sha256:936aff6bdaf542f3fa6311288e056def65bfdba420ed9577243e203da954fb7e
|
||||
size 18979575
|
||||
|
||||
Reference in New Issue
Block a user