(document: Document, newScript: string)
| 325 | } |
| 326 | |
| 327 | export function setGsapScript(document: Document, newScript: string): void { |
| 328 | const existing = findGsapScriptElement(document); |
| 329 | if (!newScript) { |
| 330 | existing?.remove(); |
| 331 | return; |
| 332 | } |
| 333 | let el = existing; |
| 334 | if (!el) { |
| 335 | el = document.createElement("script") as unknown as Element; |
| 336 | const head = |
| 337 | (document.querySelector("head") as unknown as Element | null) ?? |
| 338 | (document.body as unknown as Element); |
| 339 | (head as any).appendChild(el); |
| 340 | } |
| 341 | el.textContent = newScript; |
| 342 | } |
| 343 | |
| 344 | // ─── Sibling index ──────────────────────────────────────────────────────────── |
| 345 |
no test coverage detected