diff --git a/src/browser/js/bridge.zig b/src/browser/js/bridge.zig
index a37097e1..01df4663 100644
--- a/src/browser/js/bridge.zig
+++ b/src/browser/js/bridge.zig
@@ -576,6 +576,7 @@ pub const JsApis = flattenTypes(&.{
@import("../webapi/event/NavigationCurrentEntryChangeEvent.zig"),
@import("../webapi/event/PageTransitionEvent.zig"),
@import("../webapi/event/PopStateEvent.zig"),
+ @import("../webapi/event/UIEvent.zig"),
@import("../webapi/MessageChannel.zig"),
@import("../webapi/MessagePort.zig"),
@import("../webapi/media/MediaError.zig"),
diff --git a/src/browser/tests/event/ui.html b/src/browser/tests/event/ui.html
new file mode 100644
index 00000000..27a0f8ae
--- /dev/null
+++ b/src/browser/tests/event/ui.html
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/browser/webapi/Event.zig b/src/browser/webapi/Event.zig
index e99d71ec..614fc29b 100644
--- a/src/browser/webapi/Event.zig
+++ b/src/browser/webapi/Event.zig
@@ -60,6 +60,7 @@ pub const Type = union(enum) {
navigation_current_entry_change_event: *@import("event/NavigationCurrentEntryChangeEvent.zig"),
page_transition_event: *@import("event/PageTransitionEvent.zig"),
pop_state_event: *@import("event/PopStateEvent.zig"),
+ ui_event: *@import("event/UIEvent.zig"),
};
const Options = struct {
diff --git a/src/browser/webapi/event/UIEvent.zig b/src/browser/webapi/event/UIEvent.zig
index 13f22533..362f21ee 100644
--- a/src/browser/webapi/event/UIEvent.zig
+++ b/src/browser/webapi/event/UIEvent.zig
@@ -1,4 +1,4 @@
-// Copyright (C) 2023-2024 Lightpanda (Selecy SAS)
+// Copyright (C) 2023-2025 Lightpanda (Selecy SAS)
//
// Francis Bouvier
// Pierre Tachoire
@@ -27,19 +27,30 @@ _proto: *Event,
_detail: u32,
_view: *Window,
-pub const EventOptions = struct {
+pub const UIEventOptions = struct {
detail: u32 = 0,
view: ?*Window = null,
};
-pub fn init(typ: []const u8, _options: ?EventOptions, page: *Page) !*UIEvent {
- const options = _options orelse EventOptions{};
+const Options = Event.inheritOptions(
+ UIEvent,
+ UIEventOptions,
+);
- return page._factory.event(typ, UIEvent{
- ._proto = undefined,
- ._detail = options.detail,
- ._view = options.view,
- });
+pub fn init(typ: []const u8, _opts: ?Options, page: *Page) !*UIEvent {
+ const opts = _opts orelse Options{};
+
+ const event = try page._factory.event(
+ typ,
+ UIEvent{
+ ._proto = undefined,
+ ._detail = opts.detail,
+ ._view = opts.view orelse page.window,
+ },
+ );
+
+ Event.populatePrototypes(event, opts);
+ return event;
}
pub fn asEvent(self: *UIEvent) *Event {
@@ -56,6 +67,8 @@ pub fn getView(self: *UIEvent) *Window {
return self._view;
}
+// deprecated `initUIEvent()` not implemented
+
pub const JsApi = struct {
pub const bridge = js.Bridge(UIEvent);
@@ -69,3 +82,8 @@ pub const JsApi = struct {
pub const detail = bridge.accessor(UIEvent.getDetail, null, .{});
pub const view = bridge.accessor(UIEvent.getView, null, .{});
};
+
+const testing = @import("../../../testing.zig");
+test "WebApi: UIEvent" {
+ try testing.htmlRunner("event/ui.html", .{});
+}