mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
ScriptManager: dispatch load events for script elements
This commit is contained in:
@@ -851,6 +851,30 @@ pub const Script = struct {
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
self.executeCallback("load", local.toLocal(script_element._on_load), page);
|
self.executeCallback("load", local.toLocal(script_element._on_load), page);
|
||||||
|
|
||||||
|
// Dispatch load events if required.
|
||||||
|
const event_target = script_element.asNode().asEventTarget();
|
||||||
|
if (page._event_manager.hasListener(event_target, "load")) {
|
||||||
|
const Event = @import("webapi/Event.zig");
|
||||||
|
|
||||||
|
const event = Event.initTrusted("load", .{}, page) catch |err| {
|
||||||
|
log.warn(.js, "script internal callback", .{
|
||||||
|
.url = self.url,
|
||||||
|
.type = "load",
|
||||||
|
.err = err,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
page._event_manager.dispatch(script_element.asNode().asEventTarget(), event) catch {
|
||||||
|
log.warn(.js, "script callback", .{
|
||||||
|
.url = self.url,
|
||||||
|
.type = "load",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user