mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
add trycatch to Intersection and Performance Observers
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
const std = @import("std");
|
||||
const js = @import("../js/js.zig");
|
||||
const log = @import("../../log.zig");
|
||||
|
||||
const Page = @import("../Page.zig");
|
||||
const Element = @import("Element.zig");
|
||||
const DOMRect = @import("DOMRect.zig");
|
||||
@@ -238,7 +240,11 @@ pub fn deliverEntries(self: *IntersectionObserver, page: *Page) !void {
|
||||
}
|
||||
|
||||
const entries = try self.takeRecords(page);
|
||||
try self._callback.call(void, .{ entries, self });
|
||||
var result: js.Function.Result = undefined;
|
||||
self._callback.tryCall(void, .{ entries, self }, &result) catch |err| {
|
||||
log.err(.page, "IntsctObserver.deliverEntries", .{ .err = result.exception, .stack = result.stack });
|
||||
return err;
|
||||
};
|
||||
}
|
||||
|
||||
pub const IntersectionObserverEntry = struct {
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
const std = @import("std");
|
||||
|
||||
const js = @import("../js/js.zig");
|
||||
const log = @import("../../log.zig");
|
||||
|
||||
const Page = @import("../Page.zig");
|
||||
const Performance = @import("Performance.zig");
|
||||
|
||||
@@ -149,7 +151,11 @@ pub inline fn hasRecords(self: *const PerformanceObserver) bool {
|
||||
/// Runs the PerformanceObserver's callback with records; emptying it out.
|
||||
pub fn dispatch(self: *PerformanceObserver, page: *Page) !void {
|
||||
const records = try self.takeRecords(page);
|
||||
_ = try self._callback.call(void, .{ EntryList{ ._entries = records }, self });
|
||||
var result: js.Function.Result = undefined;
|
||||
self._callback.tryCall(void, .{ EntryList{ ._entries = records }, self }, &result) catch |err| {
|
||||
log.err(.page, "PerfObserver.dispatch", .{ .err = result.exception, .stack = result.stack });
|
||||
return err;
|
||||
};
|
||||
}
|
||||
|
||||
pub const JsApi = struct {
|
||||
|
||||
Reference in New Issue
Block a user