Jacky Zhao
2024-02-02 c00089bd5728188ce554303b5b18754467c97c85
quartz/components/scripts/spa.inline.ts
@@ -39,6 +39,9 @@
  document.dispatchEvent(event)
}
const cleanupFns: Set<(...args: any[]) => void> = new Set()
window.addCleanup = (fn) => cleanupFns.add(fn)
let p: DOMParser
async function navigate(url: URL, isBack: boolean = false) {
  p = p || new DOMParser()
@@ -57,6 +60,10 @@
  if (!contents) return
  // cleanup old
  cleanupFns.forEach((fn) => fn())
  cleanupFns.clear()
  const html = p.parseFromString(contents, "text/html")
  normalizeRelativeURLs(html, url)