diff --git a/packages/lint/src/rules/composition.test.ts b/packages/lint/src/rules/composition.test.ts index 97498b5137..c546cea634 100644 --- a/packages/lint/src/rules/composition.test.ts +++ b/packages/lint/src/rules/composition.test.ts @@ -1978,6 +1978,32 @@ ${Array.from({ length: 10 }, (_, i) => `
{ + const html = ` +
+
+
+ `; + const result = await lintHyperframeHtml(html); + expect(find(result.findings)).toBeUndefined(); + expect( + result.findings.find((f) => f.code === "root_composition_duration_derived")?.message, + ).toContain("at least 4s"); + }); + + it("derives from a negative start like the parser does", async () => { + const html = ` +
+
+
+ `; + const result = await lintHyperframeHtml(html); + expect(find(result.findings)).toBeUndefined(); + expect( + result.findings.find((f) => f.code === "root_composition_duration_derived")?.message, + ).toContain("at least 1s"); + }); + it("does not count a clip whose data-end is before its start", async () => { const html = `
diff --git a/packages/lint/src/rules/composition.ts b/packages/lint/src/rules/composition.ts index 4fb2f9a95c..0ceb0eda5d 100644 --- a/packages/lint/src/rules/composition.ts +++ b/packages/lint/src/rules/composition.ts @@ -1975,15 +1975,15 @@ function deriveDurationFromClips(tags: OpenTag[], rootTag: OpenTag) { const clipEnds: Array = []; for (const tag of tags) { if (tag === rootTag) continue; - const startRaw = readAttr(tag.raw, "data-start"); - if (startRaw === null) continue; - const start = Number(startRaw); - // A reference start ("intro+2") is resolved by the runtime; here it is a clip of unknown end. - if (!Number.isFinite(start)) { + const getAttr = (name: string) => readAttr(tag.raw, name); + if (getAttr("data-start") === null) continue; + const timing = readTagTiming(tag.raw); + // A reference start is resolved by the runtime; here it is a clip of unknown end. + if (timing.start === null) { clipEnds.push(null); continue; } - const getAttr = (name: string) => readAttr(tag.raw, name); + const start = timing.start; const authored = readAuthoredDurationSeconds(getAttr, start); if (CLIP_MEDIA_TAGS.has(tag.name)) { const { seconds } = resolveMediaDuration({