Skip to content

Commit 99b7508

Browse files
committed
support object listener on removeEventListener also
1 parent cff8857 commit 99b7508

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/browser/dom/event_target.zig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub const EventTarget = struct {
114114
pub fn _removeEventListener(
115115
self: *parser.EventTarget,
116116
typ: []const u8,
117-
cbk: Env.Function,
117+
listener: EventHandler.Listener,
118118
opts_: ?RemoveEventListenerOpts,
119119
) !void {
120120
var capture = false;
@@ -125,6 +125,8 @@ pub const EventTarget = struct {
125125
};
126126
}
127127

128+
const cbk = (try listener.callback(self)) orelse return;
129+
128130
// check if event target has already this listener
129131
const lst = try parser.eventTargetHasListener(
130132
self,
@@ -266,5 +268,9 @@ test "Browser.DOM.EventTarget" {
266268
.{ "content.addEventListener('he', obj1);", null },
267269
.{ "content.dispatchEvent(new Event('he'));", null },
268270
.{ "obj1.calls", "1" },
271+
272+
.{ "content.removeEventListener('he', obj1);", null },
273+
.{ "content.dispatchEvent(new Event('he'));", null },
274+
.{ "obj1.calls", "1" },
269275
}, .{});
270276
}

0 commit comments

Comments
 (0)