Merge pull request #57 from Browsercore/global_aliases

Alias global as self and window
This commit is contained in:
Francis Bouvier
2023-10-10 14:50:32 +02:00
committed by GitHub
4 changed files with 13 additions and 1 deletions

View File

@@ -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");

View File

@@ -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");

View File

@@ -24,6 +24,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);