Skip to content

Commit

Permalink
Allow usage of nested properties for CSP-friendly build
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoTod committed May 25, 2024
1 parent 0f7627a commit 003ce1d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/csp/src/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ function generateEvaluator(el, expression, dataStack) {
return (receiver = () => {}, { scope = {}, params = [] } = {}) => {
let completeScope = mergeProxies([scope, ...dataStack])

if (completeScope[expression] === undefined) {
throwExpressionError(el, expression)
}

runIfTypeOfFunction(receiver, completeScope[expression], completeScope, params)
let evaluatedExpression = expression.split('.').reduce(
(currentScope, currentExpression) => {
if (currentScope[currentExpression] === undefined) {
throwExpressionError(el, expression)
}

return currentScope[currentExpression]
},
completeScope,
);

runIfTypeOfFunction(receiver, evaluatedExpression, completeScope, params)
}
}

Expand Down

0 comments on commit 003ce1d

Please sign in to comment.