Skip to content

Commit ef0f399

Browse files
committed
loop: reset the loop after page end
1 parent 708abb0 commit ef0f399

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/browser/browser.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub const Session = struct {
121121
loader: Loader,
122122

123123
env: Env,
124+
loop: *Loop,
124125
inspector: jsruntime.Inspector,
125126

126127
window: Window,
@@ -143,6 +144,7 @@ pub const Session = struct {
143144
.storageShed = storage.Shed.init(allocator),
144145
.arena = std.heap.ArenaAllocator.init(allocator),
145146
.window = Window.create(null, .{ .agent = user_agent }),
147+
.loop = loop,
146148
};
147149

148150
const arena = self.arena.allocator();
@@ -278,6 +280,9 @@ pub const Page = struct {
278280

279281
// reset js env and mem arena.
280282
pub fn end(self: *Page) void {
283+
// Reset all existing callbacks.
284+
self.session.loop.reset();
285+
281286
self.session.env.stop();
282287
// TODO unload document: https://html.spec.whatwg.org/#unloading-documents
283288

0 commit comments

Comments
 (0)