diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-29 18:55:28 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-29 18:55:44 +0200 |
commit | 1499a0757a8877355a2c5983cbe63c16837a83f8 (patch) | |
tree | dcdd918eca1c2959269d6eafe132a5cb1241a988 /src/html/env.nim | |
parent | cd6b8bf5cf93ada0ee60202c249ae80693e5ca89 (diff) | |
download | chawan-1499a0757a8877355a2c5983cbe63c16837a83f8.tar.gz |
Add window.location
Note: setters do not work yet.
Diffstat (limited to 'src/html/env.nim')
-rw-r--r-- | src/html/env.nim | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/html/env.nim b/src/html/env.nim index b3c14fc5..09cf1c5c 100644 --- a/src/html/env.nim +++ b/src/html/env.nim @@ -86,8 +86,9 @@ proc screenTop(window: Window): int64 {.jsfget.} = 0 #TODO outerWidth, outerHeight proc devicePixelRatio(window: Window): float64 {.jsfget.} = 1 -func location(window: Window): URL {.jsfget.} = - window.document.location +proc setLocation(window: Window, s: string): Err[DOMException] + {.jsfset: "location".} = + window.document.setLocation(s) proc addScripting*(window: Window, selector: Selector[int]) = let rt = newJSRuntime() @@ -129,7 +130,8 @@ proc runJSJobs*(window: Window) = window.jsrt.runJSJobs(window.console.err) proc newWindow*(scripting: bool, selector: Selector[int], - attrs: WindowAttributes, loader = none(FileLoader)): Window = + attrs: WindowAttributes, navigate: proc(url: URL) = nil, + loader = none(FileLoader)): Window = let window = Window( attrs: attrs, console: console(err: newFileStream(stderr)), @@ -137,8 +139,10 @@ proc newWindow*(scripting: bool, selector: Selector[int], loader: loader, settings: EnvironmentSettings( scripting: scripting - ) + ), + navigate: navigate ) + window.location = window.newLocation() if scripting: window.addScripting(selector) return window |