mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1814 from lightpanda-io/nikneym/window-onload-alias
Make `body.onload` getter/setter alias to `window.onload`
This commit is contained in:
@@ -36,6 +36,16 @@ pub fn asNode(self: *Body) *Node {
|
|||||||
return self.asElement().asNode();
|
return self.asElement().asNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Special-case: `body.onload` is actually an alias for `window.onload`.
|
||||||
|
pub fn setOnLoad(_: *Body, callback: ?js.Function.Global, page: *Page) !void {
|
||||||
|
page.window._on_load = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Special-case: `body.onload` is actually an alias for `window.onload`.
|
||||||
|
pub fn getOnLoad(_: *Body, page: *Page) ?js.Function.Global {
|
||||||
|
return page.window._on_load;
|
||||||
|
}
|
||||||
|
|
||||||
pub const JsApi = struct {
|
pub const JsApi = struct {
|
||||||
pub const bridge = js.Bridge(Body);
|
pub const bridge = js.Bridge(Body);
|
||||||
|
|
||||||
@@ -44,6 +54,8 @@ pub const JsApi = struct {
|
|||||||
pub const prototype_chain = bridge.prototypeChain();
|
pub const prototype_chain = bridge.prototypeChain();
|
||||||
pub var class_id: bridge.ClassId = undefined;
|
pub var class_id: bridge.ClassId = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const onload = bridge.accessor(getOnLoad, setOnLoad, .{ .null_as_undefined = false });
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Build = struct {
|
pub const Build = struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user