Merge pull request #1251 from axlEscalada/axlescalada/fix-alignment-event-target

fix alignment event target
This commit is contained in:
Pierre Tachoire
2025-12-08 14:45:17 +01:00
committed by GitHub
2 changed files with 10 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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>