allow repeated registration of event on xhr

This commit is contained in:
Muki Kiboigo
2025-07-22 18:44:58 -07:00
parent 7969e047c7
commit 13e41cc180

View File

@@ -48,12 +48,7 @@ pub const XMLHttpRequestEventTarget = struct {
listener: EventHandler.Listener, listener: EventHandler.Listener,
) !?Function { ) !?Function {
const target = @as(*parser.EventTarget, @ptrCast(self)); const target = @as(*parser.EventTarget, @ptrCast(self));
const eh = (try EventHandler.register(alloc, target, typ, listener, null)) orelse return null;
// The only time this can return null if the listener is already
// registered. But before calling `register`, all of our functions
// remove any existing listener, so it should be impossible to get null
// from this function call.
const eh = (try EventHandler.register(alloc, target, typ, listener, null)) orelse unreachable;
return eh.callback; return eh.callback;
} }