mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
test(op_crates/web): add EventTarget tests (#8205)
This commit is contained in:
parent
0e5c8c03ac
commit
a8ca9fe7bb
2 changed files with 21 additions and 0 deletions
|
@ -223,3 +223,23 @@ unitTest(
|
|||
assertEquals(callCount, 2);
|
||||
},
|
||||
);
|
||||
unitTest(function eventTargetDispatchShouldSetTargetNoListener(): void {
|
||||
const target = new EventTarget();
|
||||
const event = new Event("foo");
|
||||
assertEquals(event.target, null);
|
||||
target.dispatchEvent(event);
|
||||
assertEquals(event.target, target);
|
||||
});
|
||||
|
||||
unitTest(function eventTargetDispatchShouldSetTargetInListener(): void {
|
||||
const target = new EventTarget();
|
||||
const event = new Event("foo");
|
||||
assertEquals(event.target, null);
|
||||
let called = false;
|
||||
target.addEventListener("foo", (e) => {
|
||||
assertEquals(e.target, target);
|
||||
called = true;
|
||||
});
|
||||
target.dispatchEvent(event);
|
||||
assertEquals(called, true);
|
||||
});
|
||||
|
|
|
@ -936,6 +936,7 @@
|
|||
|
||||
const listeners = eventTargetData.get(self).listeners;
|
||||
if (!(event.type in listeners)) {
|
||||
setTarget(event, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue