From 6ac4cba004f4c53e5b44bf255a85545b44bf34c6 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 27 Sep 2017 23:20:47 +1000 Subject: src/loadlib.js: If JS library returns undefined, look in window object --- src/loadlib.js | 2 ++ 1 file changed, 2 insertions(+) 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; -- cgit v1.2.3-70-g09d2