Skip to content

Commit

Permalink
Relaxes dynamic function execution of data object values
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Feb 17, 2024
1 parent 507a510 commit 184f6c4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/sutra.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,13 @@ class Sutra {
// if so, execute them and replace the value with the result
// this is to allow for dynamic data to be passed to the action
if (typeof value === 'function') {
object[key] = value(entityData, gameState, node);
// We may need to add a flag for dynamic value execution on the data object
// Remark: Do not attempt to run event listeners as value functions
// Parent APIs may call into Sutra with functions that should not be executed as values
let isEventListener = key.includes('after') || key.includes('before') || key.includes('on');
if (!isEventListener) {
object[key] = value(entityData, gameState, node);
}
} else {
object[key] = value;
}
Expand Down

0 comments on commit 184f6c4

Please sign in to comment.