Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(core): resolve composition timing without browser CSS (#5525)
Xuanru Lif09770385ee0
diff --git a/packages/core/src/runtime/startResolver.test.ts b/packages/core/src/runtime/startResolver.test.tsindex b523d618c8..486b135923 100644--- a/packages/core/src/runtime/startResolver.test.ts+++ b/packages/core/src/runtime/startResolver.test.ts@@ -438,6 +438,21 @@ describe("documentRef", () => {expect(resolver.resolveStartForElement(outro)).toBe(6);});+ it("resolves a composition reference without the browser CSS namespace", () => {+ const doc = document.implementation.createHTMLDocument("t");+ doc.body.innerHTML =+ '<div data-composition-id="intro" data-start="1" data-duration="4"></div>' ++ '<div id="outro" data-start="intro + 2"></div>';+ const css = globalThis.CSS;+ Reflect.deleteProperty(globalThis, "CSS");+ try {+ const resolver = createRuntimeStartTimeResolver({ documentRef: doc });+ expect(resolver.resolveStartForElement(doc.getElementById("outro")!)).toBe(7);+ } finally {+ globalThis.CSS = css;+ }+ });+it("defaults to the global document when documentRef is omitted", () => {const el = document.createElement("div");el.id = "ref-a";diff --git a/packages/core/src/runtime/startResolver.ts b/packages/core/src/runtime/startResolver.tsindex 51f78dc912..28c4b3d19b 100644--- a/packages/core/src/runtime/startResolver.ts+++ b/packages/core/src/runtime/startResolver.ts@@ -50,7 +50,9 @@ export function createRuntimeStartTimeResolver(params: {const byId = doc.getElementById(refId);if (byId) return byId;return (- (doc.querySelector(`[data-composition-id="${CSS.escape(refId)}"]`) as Element | null) ?? null+ Array.from(doc.querySelectorAll("[data-composition-id]")).find(+ (element) => element.getAttribute("data-composition-id") === refId,+ ) ?? null);};