Skip to content

Repeated Registering of Listener #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/browser/xhr/event_target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ pub const XMLHttpRequestEventTarget = struct {
listener: EventHandler.Listener,
) !?Function {
const target = @as(*parser.EventTarget, @ptrCast(self));

// 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;
const eh = (try EventHandler.register(alloc, target, typ, listener, null)) orelse return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we understand how this is happening? I tend to agree with the comment. This is only called from a set_xyz and all the set_xyz should unregister the existing callback, so how is EventHandler.register returning null?

return eh.callback;
}

Expand Down