use tryCall for MutationObserver records callback

Instead of `call` to avoid uncaught error
This commit is contained in:
Pierre Tachoire
2026-01-12 17:58:40 +01:00
parent 0d77ff661b
commit 92be2c45d6

View File

@@ -21,6 +21,7 @@ const js = @import("../js/js.zig");
const Page = @import("../Page.zig"); const Page = @import("../Page.zig");
const Node = @import("Node.zig"); const Node = @import("Node.zig");
const Element = @import("Element.zig"); const Element = @import("Element.zig");
const log = @import("../../log.zig");
pub fn registerTypes() []const type { pub fn registerTypes() []const type {
return &.{ return &.{
@@ -243,7 +244,11 @@ pub fn deliverRecords(self: *MutationObserver, page: *Page) !void {
// Take a copy of the records and clear the list before calling callback // Take a copy of the records and clear the list before calling callback
// This ensures mutations triggered during the callback go into a fresh list // This ensures mutations triggered during the callback go into a fresh list
const records = try self.takeRecords(page); const records = try self.takeRecords(page);
try self._callback.call(void, .{ records, self }); var result: js.Function.Result = undefined;
self._callback.tryCall(void, .{ records, self }, &result) catch |err| {
log.err(.page, "MutObserver.deliverRecords", .{ .err = result.exception, .stack = result.stack });
return err;
};
} }
pub const MutationRecord = struct { pub const MutationRecord = struct {