From bd9c63f22fc02a6e5d319e3a9c159fab9ed4917c Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 21 Dec 2023 11:35:43 +0100 Subject: [PATCH] browser: update window injection TODO --- src/browser/browser.zig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/browser/browser.zig b/src/browser/browser.zig index 6adbfdda..d613031f 100644 --- a/src/browser/browser.zig +++ b/src/browser/browser.zig @@ -143,9 +143,17 @@ pub const Page = struct { // add global objects log.debug("setup global env", .{}); const window = Window.create(doc, null); - // TODO should'nt we share the same pointer between instances of window? - try self.env.addObject(apis, window, "self"); + + // TODO we must share the same pointer between window and self. + // once https://github.com/lightpanda-io/jsruntime-lib/issues/171 is + // done, replace the 2 lines with: + // + // const obj = try js_env.addObject(apis, window, "window"); + // try js_env.attachObject(try js_env.getGlobal(), "self", obj); + // try self.env.addObject(apis, window, "window"); + try self.env.addObject(apis, window, "self"); + try self.env.addObject(apis, doc, "document"); } };