fix(core): a video with no size of its own keeps its file's size in the preview (#8211)

This commit is contained in:
Miguel Ángel
2026-11-18 20:17:21 +00:00
committed by GitHub
parent d205e59487
commit e9eac3f9d4
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -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");
+1 -1
View File
@@ -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";