about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-08-15 18:40:32 +0200
committerbptato <nincsnevem662@gmail.com>2023-08-15 18:40:32 +0200
commit530bacb96044e7635be3b4968ee1192616d659d1 (patch)
tree23cc32622a0013c319c82b860b0e1cee3a47f34a
parentaea27f52335d203f8acfed3f2113ab0e61cdafd5 (diff)
downloadchawan-530bacb96044e7635be3b4968ee1192616d659d1.tar.gz
chadombuilder: implement restart
Now pages (once again) do not break when a meta charset tag is
defined. Hooray!
-rw-r--r--src/html/chadombuilder.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/html/chadombuilder.nim b/src/html/chadombuilder.nim
index 13bad12c..f089b134 100644
--- a/src/html/chadombuilder.nim
+++ b/src/html/chadombuilder.nim
@@ -33,6 +33,17 @@ proc finish(builder: DOMBuilder[Node]) =
     script.execute()
   #TODO events
 
+proc restart(builder: DOMBuilder[Node]) =
+  let document = newDocument()
+  document.contentType = "text/html"
+  let oldDocument = cast[Document](builder.document)
+  document.url = oldDocument.url
+  let window = oldDocument.window
+  if window != nil:
+    document.window = window
+    window.document = document
+  builder.document = document
+
 proc parseError(builder: DOMBuilder[Node], message: string) =
   discard
 
@@ -155,6 +166,7 @@ proc newChaDOMBuilder(url: URL, window: Window): ChaDOMBuilder =
   return ChaDOMBuilder(
     document: document,
     finish: finish,
+    restart: restart,
     setQuirksMode: setQuirksMode,
     setCharacterSet: setCharacterset,
     elementPopped: elementPopped,