From f4880c0098391788d8b582cc47c37da32fa88ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horacio=20Pe=C3=B1a?= Date: Tue, 8 Oct 2024 10:50:35 -0300 Subject: [PATCH 1/2] failing test --- async.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) 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( From 853f0dd673a52c4f468329995c0e84cf65af839a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horacio=20Pe=C3=B1a?= Date: Tue, 8 Oct 2024 10:52:34 -0300 Subject: [PATCH 2/2] fix function check: context is already at originalcontext[key] --- defaultMethods.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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