mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
Don't require handleEvent function to be on object event listener
When registering an object as an event listener, the handleEvent function doesn't have to be defined then and there. The handleEvent function can be added at any point in the future.
This commit is contained in:
@@ -67,12 +67,6 @@ pub const EventListenerCallback = union(enum) {
|
||||
pub fn addEventListener(self: *EventTarget, typ: []const u8, callback_: ?EventListenerCallback, opts_: ?AddEventListenerOptions, page: *Page) !void {
|
||||
const callback = callback_ orelse return;
|
||||
|
||||
if (callback == .object) {
|
||||
if (try callback.object.getFunction("handleEvent") == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const em_callback = switch (callback) {
|
||||
.function => |func| EventManager.Callback{ .function = func },
|
||||
.object => |obj| EventManager.Callback{ .object = try obj.persist() },
|
||||
|
||||
Reference in New Issue
Block a user