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

Function getAttr

packages/core/src/compiler/timingCompiler.ts:62–71  ·  view source on GitHub ↗
(tag: string, attr: string)

Source from the content-addressed store, hash-verified

60// ── Helpers ──────────────────────────────────────────────────────────────
61
62function getAttr(tag: string, attr: string): string | null {
63 // `(?<![\w-])` anchors the attribute name to a fresh start. Without it,
64 // `getAttr(tag, "id")` matches the trailing `id="…"` inside `data-hf-id="…"`
65 // (and "src" inside `data-src`, etc.) and returns a phantom value. That bug
66 // made compileTag believe a Studio-stamped `data-hf-id`-only element already
67 // had an `id`, so it skipped its `hf-video-N` injection — leaving the element
68 // with no real `el.id`, which the render pipeline keys off of (blank wash).
69 const match = tag.match(new RegExp(`(?<![\\w-])${attr}=["']([^"']+)["']`));
70 return match ? (match[1] ?? null) : null;
71}
72
73function hasAttr(tag: string, attr: string): boolean {
74 return new RegExp(`\\s${attr}(?:\\s|=|>|/)`).test(tag);

Callers 6

rewriteAssetPathsFunction · 0.85
compileTagFunction · 0.85
compileTimingAttrsFunction · 0.85
injectDurationsFunction · 0.85
extractResolvedMediaFunction · 0.85
clampDurationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected