From 230ad7876ed5f8f26dce02db0e3528a5539150f4 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 20 Aug 2023 16:01:06 +0200 Subject: javascript: finish LegacyUnforgeable + misc fixes Add jsuffget, jsuffunc for setting LegacyUnforgeable on functions. Misc fixes: * define LegacyUnforgeable properties for native object shims * replace some macros with templates --- src/html/env.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/html/env.nim') diff --git a/src/html/env.nim b/src/html/env.nim index 97f202f9..c38852d5 100644 --- a/src/html/env.nim +++ b/src/html/env.nim @@ -93,6 +93,9 @@ proc setLocation(window: Window, s: string): Err[DOMException] {.jsfset: "location".} = window.document.setLocation(s) +proc getWindow(window: Window): Window {.jsuffget: "window".} = + return window + proc addScripting*(window: Window, selector: Selector[int]) = let rt = newJSRuntime() let ctx = rt.newJSContext() @@ -115,7 +118,6 @@ proc addScripting*(window: Window, selector: Selector[int]) = var global = JS_GetGlobalObject(ctx) ctx.registerType(Window, asglobal = true) ctx.setGlobal(global, window) - ctx.defineProperty(global, "window", global) JS_FreeValue(ctx, global) ctx.addDOMExceptionModule() ctx.addconsoleModule() -- cgit 1.4.1-2-gfad0