mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Merge pull request #232 from lightpanda-io/fix-window-global
browser: fix global object window
This commit is contained in:
@@ -273,7 +273,7 @@ pub const Page = struct {
|
|||||||
|
|
||||||
// add global objects
|
// add global objects
|
||||||
log.debug("setup global env", .{});
|
log.debug("setup global env", .{});
|
||||||
try self.session.env.bindGlobal(self.session.window);
|
try self.session.env.bindGlobal(&self.session.window);
|
||||||
|
|
||||||
// browse the DOM tree to retrieve scripts
|
// browse the DOM tree to retrieve scripts
|
||||||
// TODO execute the synchronous scripts during the HTL parsing.
|
// TODO execute the synchronous scripts during the HTL parsing.
|
||||||
@@ -359,6 +359,8 @@ pub const Page = struct {
|
|||||||
// have loaded.
|
// have loaded.
|
||||||
// https://html.spec.whatwg.org/#reporting-document-loading-status
|
// https://html.spec.whatwg.org/#reporting-document-loading-status
|
||||||
const evt = try parser.eventCreate();
|
const evt = try parser.eventCreate();
|
||||||
|
defer parser.eventDestroy(evt);
|
||||||
|
|
||||||
try parser.eventInit(evt, "DOMContentLoaded", .{ .bubbles = true, .cancelable = true });
|
try parser.eventInit(evt, "DOMContentLoaded", .{ .bubbles = true, .cancelable = true });
|
||||||
_ = try parser.eventTargetDispatchEvent(parser.toEventTarget(parser.DocumentHTML, html_doc), evt);
|
_ = try parser.eventTargetDispatchEvent(parser.toEventTarget(parser.DocumentHTML, html_doc), evt);
|
||||||
|
|
||||||
@@ -373,8 +375,13 @@ pub const Page = struct {
|
|||||||
|
|
||||||
// dispatch window.load event
|
// dispatch window.load event
|
||||||
const loadevt = try parser.eventCreate();
|
const loadevt = try parser.eventCreate();
|
||||||
|
defer parser.eventDestroy(loadevt);
|
||||||
|
|
||||||
try parser.eventInit(loadevt, "load", .{});
|
try parser.eventInit(loadevt, "load", .{});
|
||||||
_ = try parser.eventTargetDispatchEvent(parser.toEventTarget(Window, &self.session.window), loadevt);
|
_ = try parser.eventTargetDispatchEvent(
|
||||||
|
parser.toEventTarget(Window, &self.session.window),
|
||||||
|
loadevt,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// evalScript evaluates the src in priority.
|
// evalScript evaluates the src in priority.
|
||||||
|
|||||||
Reference in New Issue
Block a user