diff --git a/packages/core/src/runtime/init.test.ts b/packages/core/src/runtime/init.test.ts index ba3fb47559..e5e4927f92 100644 --- a/packages/core/src/runtime/init.test.ts +++ b/packages/core/src/runtime/init.test.ts @@ -5945,6 +5945,22 @@ describe("initSandboxRuntimeModular", () => { expect(logo.style.width).toBe("340px"); }); + it("leaves a video with no size of its own at its file's size while its file loads", () => { + const root = makeRoot(); + const clip = document.createElement("video"); + clip.setAttribute("data-start", "0"); + clip.setAttribute("data-duration", "5"); + root.appendChild(clip); + // A video waiting for its source measures 0px; once loaded it takes its file's size, as a render draws it. + modelBrowserLayout(clip, { width: "0px", height: "0px" }); + + window.__timelines = { main: createMockTimeline(10) }; + initSandboxRuntimeModular(); + + expect(clip.style.width).toBe(""); + expect(clip.style.height).toBe(""); + }); + it("puts back an author's display:none !important after measuring the clip", () => { const root = makeRoot(); const card = document.createElement("div"); diff --git a/packages/core/src/runtime/init.ts b/packages/core/src/runtime/init.ts index ae27a4fa59..432d4e0e4f 100644 --- a/packages/core/src/runtime/init.ts +++ b/packages/core/src/runtime/init.ts @@ -1085,7 +1085,7 @@ export function initSandboxRuntimeModular(): void { el.style.position = "absolute"; } if (tag !== "audio") { - const sizedByItsFile = tag === "img"; + const sizedByItsFile = tag === "img" || tag === "video"; const forcedWidth = parseDimensionPx(el.getAttribute("data-width")); const forcedHeight = parseDimensionPx(el.getAttribute("data-height")); const hasMeaningfulComputedWidth = computed.width !== "0px" && computed.width !== "auto";