about summary refs log tree commit diff stats
path: root/src/html/env.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/html/env.nim')
-rw-r--r--src/html/env.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/html/env.nim b/src/html/env.nim
index e8fbf4af..0a90007f 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -138,7 +138,9 @@ proc devicePixelRatio(window: Window): float64 {.jsfget.} = 1
 
 proc setLocation(window: Window; s: string): Err[JSError]
     {.jsfset: "location".} =
-  window.document.setLocation(s)
+  if window.document == nil:
+    return errTypeError("document is null")
+  return window.document.setLocation(s)
 
 func getWindow(window: Window): Window {.jsuffget: "window".} =
   return window