summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/loadlib.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index 7a50556..4116b0a 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -58,6 +58,8 @@ if (WEB) {
let res = func(fengari);
if (typeof res === "function" || (typeof res === "object" && res !== null)) {
return res;
+ } else if (res === void 0) { /* assume library added symbols to global environment */
+ return window;
} else {
lua.lua_pushstring(L, lua.to_luastring(`library returned unexpected type (${typeof res})`));
return null;