mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-08 19:06:04 +00:00
feat(core): export runtime start resolver with documentRef parameter
This commit is contained in:
@@ -399,3 +399,35 @@ describe("createRuntimeStartTimeResolver", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("documentRef", () => {
|
||||
it("resolves references against a supplied document instead of the global one", () => {
|
||||
const doc = document.implementation.createHTMLDocument("t");
|
||||
const intro = doc.createElement("div");
|
||||
intro.id = "intro";
|
||||
intro.setAttribute("data-start", "0");
|
||||
intro.setAttribute("data-duration", "4");
|
||||
doc.body.appendChild(intro);
|
||||
const outro = doc.createElement("div");
|
||||
outro.setAttribute("data-start", "intro + 2");
|
||||
doc.body.appendChild(outro);
|
||||
|
||||
const resolver = createRuntimeStartTimeResolver({ documentRef: doc });
|
||||
// intro ends at 0 + 4; outro starts 2s after → 6.
|
||||
expect(resolver.resolveStartForElement(outro)).toBe(6);
|
||||
});
|
||||
|
||||
it("defaults to the global document when documentRef is omitted", () => {
|
||||
const el = document.createElement("div");
|
||||
el.id = "ref-a";
|
||||
el.setAttribute("data-start", "0");
|
||||
el.setAttribute("data-duration", "2");
|
||||
document.body.appendChild(el);
|
||||
const dependent = document.createElement("div");
|
||||
dependent.setAttribute("data-start", "ref-a");
|
||||
document.body.appendChild(dependent);
|
||||
|
||||
const resolver = createRuntimeStartTimeResolver({});
|
||||
expect(resolver.resolveStartForElement(dependent)).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user