diff --git a/src/browser/js/Caller.zig b/src/browser/js/Caller.zig index 9f48d345..b999c6e0 100644 --- a/src/browser/js/Caller.zig +++ b/src/browser/js/Caller.zig @@ -35,6 +35,7 @@ const IS_DEBUG = @import("builtin").mode == .Debug; const Caller = @This(); local: js.Local, prev_local: ?*const js.Local, +prev_context: *Context, // Takes the raw v8 isolate and extracts the context from it. pub fn init(self: *Caller, v8_isolate: *v8.Isolate) void { @@ -53,7 +54,9 @@ pub fn init(self: *Caller, v8_isolate: *v8.Isolate) void { .isolate = .{ .handle = v8_isolate }, }, .prev_local = ctx.local, + .prev_context = ctx.page.js, }; + ctx.page.js = ctx; ctx.local = &self.local; } @@ -79,6 +82,7 @@ pub fn deinit(self: *Caller) void { ctx.call_depth = call_depth; ctx.local = self.prev_local; + ctx.page.js = self.prev_context; } pub const CallOpts = struct {