mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
support object listener on removeEventListener also
This commit is contained in:
@@ -114,7 +114,7 @@ pub const EventTarget = struct {
|
|||||||
pub fn _removeEventListener(
|
pub fn _removeEventListener(
|
||||||
self: *parser.EventTarget,
|
self: *parser.EventTarget,
|
||||||
typ: []const u8,
|
typ: []const u8,
|
||||||
cbk: Env.Function,
|
listener: EventHandler.Listener,
|
||||||
opts_: ?RemoveEventListenerOpts,
|
opts_: ?RemoveEventListenerOpts,
|
||||||
) !void {
|
) !void {
|
||||||
var capture = false;
|
var capture = false;
|
||||||
@@ -125,6 +125,8 @@ pub const EventTarget = struct {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cbk = (try listener.callback(self)) orelse return;
|
||||||
|
|
||||||
// check if event target has already this listener
|
// check if event target has already this listener
|
||||||
const lst = try parser.eventTargetHasListener(
|
const lst = try parser.eventTargetHasListener(
|
||||||
self,
|
self,
|
||||||
@@ -266,5 +268,9 @@ test "Browser.DOM.EventTarget" {
|
|||||||
.{ "content.addEventListener('he', obj1);", null },
|
.{ "content.addEventListener('he', obj1);", null },
|
||||||
.{ "content.dispatchEvent(new Event('he'));", null },
|
.{ "content.dispatchEvent(new Event('he'));", null },
|
||||||
.{ "obj1.calls", "1" },
|
.{ "obj1.calls", "1" },
|
||||||
|
|
||||||
|
.{ "content.removeEventListener('he', obj1);", null },
|
||||||
|
.{ "content.dispatchEvent(new Event('he'));", null },
|
||||||
|
.{ "obj1.calls", "1" },
|
||||||
}, .{});
|
}, .{});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user