(html: string)
| 17 | } |
| 18 | |
| 19 | export function parseMutable(html: string): ParsedDocument { |
| 20 | const stamped = ensureHfIds(html); |
| 21 | const hasShell = /<!doctype|<html[\s>]/i.test(stamped); |
| 22 | const wrapped = !hasShell; |
| 23 | const { document } = wrapped |
| 24 | ? parseHTML(`<!DOCTYPE html><html><head></head><body>${stamped}</body></html>`) |
| 25 | : parseHTML(stamped); |
| 26 | return { document: document as unknown as Document, wrapped, stamped }; |
| 27 | } |
| 28 | |
| 29 | // ─── Element lookup ─────────────────────────────────────────────────────────── |
| 30 |