about summary refs log tree commit diff stats
path: root/src/server/buffer.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-11-27 19:23:35 +0100
committerbptato <nincsnevem662@gmail.com>2023-11-27 19:23:35 +0100
commit7fae592de5beaa88bf82b497a3bf06be372d20cb (patch)
treec42791cf9888316ce99c5e35505b39371fed5e31 /src/server/buffer.nim
parent860893abaefef5f95537e584c9325e23ecb1b394 (diff)
downloadchawan-7fae592de5beaa88bf82b497a3bf06be372d20cb.tar.gz
dom: add document.readyState
Diffstat (limited to 'src/server/buffer.nim')
-rw-r--r--src/server/buffer.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim
index fa134d8f..82774fe7 100644
--- a/src/server/buffer.nim
+++ b/src/server/buffer.nim
@@ -1069,9 +1069,10 @@ proc finishLoad(buffer: Buffer): EmptyPromise =
     if buffer.window == nil:
       buffer.window = newWindow(buffer.config.scripting, buffer.selector,
         buffer.attrs)
-    let doc = parseHTML(buffer.sstream, charsets = buffer.charsets,
+    let document = parseHTML(buffer.sstream, charsets = buffer.charsets,
       window = buffer.window, url = buffer.url)
-    buffer.document = doc
+    buffer.document = document
+    document.readyState = READY_STATE_INTERACTIVE
     buffer.state = LOADING_RESOURCES
     buffer.dispatchDOMContentLoadedEvent()
     p = buffer.loadResources()
@@ -1136,6 +1137,7 @@ proc onload(buffer: Buffer) =
       res.atend = true
       buffer.finishLoad().then(proc() =
         buffer.state = LOADED
+        buffer.document.readyState = READY_STATE_COMPLETE
         buffer.dispatchLoadEvent()
         buffer.resolveTask(LOAD, res))
       return