summaryrefslogtreecommitdiff
path: root/src/loadlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-09-27 23:20:47 +1000
committerdaurnimator <quae@daurnimator.com>2017-09-27 23:20:47 +1000
commit6ac4cba004f4c53e5b44bf255a85545b44bf34c6 (patch)
tree8530cf6a7256c0b5a2015cb0c01d4a7e8e8e2b88 /src/loadlib.js
parentc8d109ee3634ec8973338bdbf73dbaf3bd20afe5 (diff)
downloadfengari-6ac4cba004f4c53e5b44bf255a85545b44bf34c6.tar.gz
fengari-6ac4cba004f4c53e5b44bf255a85545b44bf34c6.tar.bz2
fengari-6ac4cba004f4c53e5b44bf255a85545b44bf34c6.zip
src/loadlib.js: If JS library returns undefined, look in window object
Diffstat (limited to 'src/loadlib.js')
-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;