mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
event_target: handle window target
This commit is contained in:
@@ -29,6 +29,7 @@ const EventHandler = @import("../events/event.zig").EventHandler;
|
|||||||
|
|
||||||
const DOMException = @import("exceptions.zig").DOMException;
|
const DOMException = @import("exceptions.zig").DOMException;
|
||||||
const Nod = @import("node.zig");
|
const Nod = @import("node.zig");
|
||||||
|
const Window = @import("../html/window.zig").Window;
|
||||||
|
|
||||||
// EventTarget interfaces
|
// EventTarget interfaces
|
||||||
pub const Union = Nod.Union;
|
pub const Union = Nod.Union;
|
||||||
@@ -40,9 +41,10 @@ pub const EventTarget = struct {
|
|||||||
pub const mem_guarantied = true;
|
pub const mem_guarantied = true;
|
||||||
|
|
||||||
pub fn toInterface(et: *parser.EventTarget) !Union {
|
pub fn toInterface(et: *parser.EventTarget) !Union {
|
||||||
// NOTE: for now we state that all EventTarget are Nodes
|
return switch (try parser.eventTargetGetType(et)) {
|
||||||
// TODO: handle other types (eg. Window)
|
.window => .{ .Window = @as(*Window, @ptrCast(et)) },
|
||||||
return Nod.Node.toInterface(@as(*parser.Node, @ptrCast(et)));
|
.node => Nod.Node.toInterface(@as(*parser.Node, @ptrCast(et))),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// JS funcs
|
// JS funcs
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ pub const Window = struct {
|
|||||||
return Window{
|
return Window{
|
||||||
.target = target orelse "",
|
.target = target orelse "",
|
||||||
.navigator = navigator orelse .{},
|
.navigator = navigator orelse .{},
|
||||||
|
.base = .{ .et_type = @intFromEnum(parser.EventTargetType.window) },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user