diff --git a/async.test.js b/async.test.js index 7d2fb6f..a919b2b 100644 --- a/async.test.js +++ b/async.test.js @@ -826,6 +826,17 @@ modes.forEach((logic) => { ).toBe(null) }) + test('allow access to objects named as their methods', async () => { + expect( + await logic.run( + { + var: 'toString' + }, + {toString: 'hello'} + ) + ).toBe("hello") + }) + test('allow access to functions on objects when enabled', async () => { logic.allowFunctions = true expect( diff --git a/defaultMethods.js b/defaultMethods.js index 84b7ecf..93dba79 100644 --- a/defaultMethods.js +++ b/defaultMethods.js @@ -217,7 +217,7 @@ const defaultMethods = { return notFound } } - if (engine.allowFunctions || typeof (context && context[key]) !== 'function') { + if (engine.allowFunctions || typeof context !== 'function') { return context } return null