Skip to content

Commit 229844d

Browse files
committed
browser: use *const Script with evalScript
1 parent 3fd8347 commit 229844d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/browser/browser.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ pub const Page = struct {
512512
// > page.
513513
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes
514514
try parser.documentHTMLSetCurrentScript(html_doc, @ptrCast(e));
515-
self.evalScript(script) catch |err| log.warn("evaljs: {any}", .{err});
515+
self.evalScript(&script) catch |err| log.warn("evaljs: {any}", .{err});
516516
try parser.documentHTMLSetCurrentScript(html_doc, null);
517517
}
518518

@@ -531,7 +531,7 @@ pub const Page = struct {
531531
// eval async scripts.
532532
for (sasync.items) |s| {
533533
try parser.documentHTMLSetCurrentScript(html_doc, @ptrCast(s.element));
534-
self.evalScript(s) catch |err| log.warn("evaljs: {any}", .{err});
534+
self.evalScript(&s) catch |err| log.warn("evaljs: {any}", .{err});
535535
try parser.documentHTMLSetCurrentScript(html_doc, null);
536536
}
537537

@@ -553,8 +553,8 @@ pub const Page = struct {
553553
// evalScript evaluates the src in priority.
554554
// if no src is present, we evaluate the text source.
555555
// https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model
556-
fn evalScript(self: *Page, s: Script) !void {
557-
self.current_script = &s;
556+
fn evalScript(self: *Page, s: *const Script) !void {
557+
self.current_script = s;
558558
defer self.current_script = null;
559559

560560
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-script
@@ -647,8 +647,9 @@ pub const Page = struct {
647647

648648
// fetchScript senf a GET request to the src and execute the script
649649
// received.
650-
fn fetchScript(self: *Page, s: Script) !void {
650+
fn fetchScript(self: *Page, s: *const Script) !void {
651651
const arena = self.arena;
652+
652653
const body = try self.fetchData(arena, s.src, null);
653654
// TODO: change to &self.session.env when
654655
// https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands

0 commit comments

Comments
 (0)