MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / findRootCompositionEl

Function findRootCompositionEl

packages/core/src/runtime/init.ts:139–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137 // array-normalization + data-start defaults below pick the same root the
138 // closure-based `resolveRootCompositionElement` does on multi-comp pages.
139 const findRootCompositionEl = (): HTMLElement | null => {
140 const explicitRoot = document.querySelector('[data-composition-id][data-root="true"]');
141 if (explicitRoot instanceof HTMLElement) return explicitRoot;
142 const nodes = Array.from(document.querySelectorAll("[data-composition-id]")) as HTMLElement[];
143 return (
144 nodes.find((node) => !node.parentElement?.closest("[data-composition-id]")) ??
145 nodes[0] ??
146 null
147 );
148 };
149
150 // Agents often write `window.__timelines = [tl]` (array) instead of the
151 // keyed-by-composition-id object the runtime expects. Normalize at init so

Callers 2

Calls 3

fromMethod · 0.80
querySelectorMethod · 0.65
findMethod · 0.65

Tested by

no test coverage detected