Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/browser/dom/event_target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub const EventTarget = struct {
// --------
pub fn constructor(page: *Page) !*parser.EventTarget {
const et = try page.arena.create(EventTarget);
et.* = .{};
return @ptrCast(&et.base);
}

Expand Down
9 changes: 9 additions & 0 deletions src/tests/dom/event_target.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,13 @@
// doesn't crash on null receiver
content.addEventListener('he2', null);
content.dispatchEvent(new Event('he2'));

// Test that EventTarget constructor properly initializes vtable
const et = new EventTarget();
testing.expectEqual('[object EventTarget]', et.toString());

let constructorTestCalled = false;
et.addEventListener('test', () => { constructorTestCalled = true; });
et.dispatchEvent(new Event('test'));
testing.expectEqual(true, constructorTestCalled);
</script>