(tag: string, attr: string)
| 60 | // ── Helpers ────────────────────────────────────────────────────────────── |
| 61 | |
| 62 | function 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 | |
| 73 | function hasAttr(tag: string, attr: string): boolean { |
| 74 | return new RegExp(`\\s${attr}(?:\\s|=|>|/)`).test(tag); |
no outgoing calls
no test coverage detected