From 84a949e7c76afb57de94391e76970be3bc643a5b Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Sun, 1 Mar 2026 18:00:00 +0800 Subject: [PATCH] Fix load event for page with no external scripts but with iframes Previously the "load" event happened when all external scripts were done. In the case that there was no external script, the "load" event would fire immediately after parsing. With iframes, it now waits for external script AND iframes to complete but the no-external-script code was never updated to consider iframes and would thus fire load events prematurely. --- src/browser/Page.zig | 5 ----- src/browser/ScriptManager.zig | 6 ------ 2 files changed, 11 deletions(-) diff --git a/src/browser/Page.zig b/src/browser/Page.zig index 1b068374..e2ec7885 100644 --- a/src/browser/Page.zig +++ b/src/browser/Page.zig @@ -866,11 +866,6 @@ fn pageDoneCallback(ctx: *anyopaque) !void { .html => |buf| { parser.parse(buf.items); self._script_manager.staticScriptsDone(); - if (self._script_manager.isDone()) { - // No scripts, or just inline scripts that were already processed - // we need to trigger this ourselves - self.documentIsComplete(); - } self._parse_state = .complete; }, .text => |*buf| { diff --git a/src/browser/ScriptManager.zig b/src/browser/ScriptManager.zig index 403a1199..61d4aef0 100644 --- a/src/browser/ScriptManager.zig +++ b/src/browser/ScriptManager.zig @@ -582,12 +582,6 @@ fn evaluate(self: *ScriptManager) void { } } -pub fn isDone(self: *const ScriptManager) bool { - return self.static_scripts_done and // page is done processing initial html - self.defer_scripts.first == null and // no deferred scripts - self.async_scripts.first == null; // no async scripts -} - fn parseImportmap(self: *ScriptManager, script: *const Script) !void { const content = script.source.content();