(items: JSItem[], context?: unknown)
| 59 | } |
| 60 | |
| 61 | export function persistJS(items: JSItem[], context?: unknown): string[] { |
| 62 | return items.map((item) => { |
| 63 | if (item.type === 'script') { |
| 64 | const { textContent, ...rest } = item.data; |
| 65 | return wrapHtml( |
| 66 | 'script', |
| 67 | textContent || '', |
| 68 | rest as Record<string, string | boolean>, |
| 69 | ); |
| 70 | } |
| 71 | if (item.type === 'iife') { |
| 72 | const { fn, getParams } = item.data; |
| 73 | return wrapHtml( |
| 74 | 'script', |
| 75 | escapeScript(buildCode(fn, getParams?.(context) || [])), |
| 76 | ); |
| 77 | } |
| 78 | return ''; |
| 79 | }); |
| 80 | } |
| 81 | |
| 82 | export function persistCSS(items: CSSItem[]): string[] { |
| 83 | return items.map((item) => { |
no test coverage detected