browser: inject window global object

This commit is contained in:
Pierre Tachoire committed 2024-01-17 18:21:48 +01:00
1 parent 6ff121334f
commit 0d32fc62ba
3 files changed
+6 -7

No files matched your search

+2 -3
View File
@@ -143,10 +143,9 @@ pub const Page = struct {
// add global objects
log.debug("setup global env", .{});
const window = Window.create(doc, null);
_ = window;
// TODO should'nt we share the same pointer between instances of window?
// try js_env.addObject(apis, window, "self");
// try js_env.addObject(apis, window, "window");
try self.env.addObject(apis, window, "self");
try self.env.addObject(apis, window, "window");
try self.env.addObject(apis, doc, "document");
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
const generate = @import("../generate.zig");
const Window = @import("window.zig");
const Window = @import("window.zig").Window;
pub const Interfaces = generate.Tuple(.{
Window,
+3 -3
View File
@@ -17,15 +17,15 @@ pub const Window = struct {
};
}
pub fn get_window(self: *Window) *parser.Document {
pub fn get_window(self: *Window) *Window {
return self;
}
pub fn get_self(self: *Window) *parser.Document {
pub fn get_self(self: *Window) *Window {
return self;
}
pub fn get_parent(self: *Window) *parser.Document {
pub fn get_parent(self: *Window) *Window {
return self;
}