Skip to content

Write HTML. Render video. Built for agents.

fix(caption-editorial-emphasis,caption-emoji-pop): remove O(n^2) redundant hide-all-others loop

vanceingalls18de2b1f1de8
diff --git a/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html b/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html
index 281c3aae76..f859ab6aeb 100644
--- a/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html
+++ b/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html
@@ -586,9 +586,14 @@
var start = blockStart(bi);
var nextStart = bi < BLOCKS.length - 1 ? blockStart(bi + 1) : DURATION;
- allEls.forEach(function (other, oi) {
- if (oi !== bi) tl.set(other, { opacity: 0 }, start);
- });
+ // Each block already owns its full opacity lifecycle (set 1 at its
+ // own start, then set back to 0 at its own nextStart below), and
+ // blocks occupy non-overlapping windows, so explicitly hiding every
+ // OTHER block here was redundant and made timeline construction
+ // O(blocks^2) — this collapsed under dense stress transcripts (many
+ // single-word emphasis blocks). Removed; behavior is unchanged
+ // (verified against templates.test.ts).
+
tl.set(el, { opacity: 1 }, start);
block.line1.forEach(function (pair, wi) {
diff --git a/registry/components/caption-emoji-pop/caption-emoji-pop.html b/registry/components/caption-emoji-pop/caption-emoji-pop.html
index d4107123b0..da1692a5fa 100644
--- a/registry/components/caption-emoji-pop/caption-emoji-pop.html
+++ b/registry/components/caption-emoji-pop/caption-emoji-pop.html
@@ -703,9 +703,13 @@
groupIndex < GROUPS.length - 1 ? visibleStarts[groupIndex + 1] : DURATION;
var exitStart = Math.max(visibleStart, visibleEnd - EXIT_DURATION);
- allGroupEls.forEach(function (otherEl, otherIndex) {
- if (otherIndex !== groupIndex) tl.set(otherEl, { opacity: 0 }, visibleStart);
- });
+ // Each group already owns its full opacity lifecycle (set 0 at its
+ // own visibleStart, animated to 1, then set back to 0 at its own
+ // visibleEnd below), and groups occupy non-overlapping windows, so
+ // explicitly hiding every OTHER group here was redundant and made
+ // timeline construction O(groups^2) — this collapsed under dense
+ // stress transcripts (many short groups). Removed; behavior is
+ // unchanged (verified against templates.test.ts).
tl.set(groupEl, { opacity: 0, scaleX: 0.8, scaleY: 1 }, visibleStart);
tl.to(