From 28b1bee241e588535832bc4fa71a3245b0539c6b Mon Sep 17 00:00:00 2001 From: Francis Bouvier Date: Tue, 10 Oct 2023 14:49:57 +0200 Subject: [PATCH] Alias global as self and window Signed-off-by: Francis Bouvier --- src/main.zig | 4 ++++ src/main_shell.zig | 4 ++++ src/run_tests.zig | 4 ++++ vendor/jsruntime-lib | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index a175929f..580e8971 100644 --- a/src/main.zig +++ b/src/main.zig @@ -20,6 +20,10 @@ fn execJS( js_env.start(apis); defer js_env.stop(); + // alias global as self and window + try js_env.attachObject(try js_env.getGlobal(), "self", null); + try js_env.attachObject(try js_env.getGlobal(), "window", null); + // add document object try js_env.addObject(apis, doc, "document"); diff --git a/src/main_shell.zig b/src/main_shell.zig index e9acdc9d..e55facb5 100644 --- a/src/main_shell.zig +++ b/src/main_shell.zig @@ -19,6 +19,10 @@ fn execJS( js_env.start(apis); defer js_env.stop(); + // alias global as self and window + try js_env.attachObject(try js_env.getGlobal(), "self", null); + try js_env.attachObject(try js_env.getGlobal(), "window", null); + // add document object try js_env.addObject(apis, doc, "document"); diff --git a/src/run_tests.zig b/src/run_tests.zig index bb036659..65ace233 100644 --- a/src/run_tests.zig +++ b/src/run_tests.zig @@ -23,6 +23,10 @@ fn testExecFn( js_env.start(apis); defer js_env.stop(); + // alias global as self and window + try js_env.attachObject(try js_env.getGlobal(), "self", null); + try js_env.attachObject(try js_env.getGlobal(), "window", null); + // document doc = try parser.documentHTMLParseFromFileAlloc(std.testing.allocator, "test.html"); defer parser.documentHTMLClose(doc); diff --git a/vendor/jsruntime-lib b/vendor/jsruntime-lib index c2200495..3c64a17a 160000 --- a/vendor/jsruntime-lib +++ b/vendor/jsruntime-lib @@ -1 +1 @@ -Subproject commit c22004957dd52e3d6566ea9b2b1fb2e2f184b9c8 +Subproject commit 3c64a17a630b154a96702e6f272f925ff95e0504