You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have more a point referent at using your (amazing) lib than exactly a bug.
In Salesforce Lighting Web Component the eval function have fixed scope, that means the "this" will always be the global window and you can't change that.
That makes the 'noSandbox = false' to not work because the iframe create won't even have an eval function.
And in 'noSandbox = true' you will face the issue with the scope.
I found a solution for what I'm using that either involve INS and HTML.
For INS I used a function passing the scope.
While for HTML I got the content direct (that has the ` comenda for variable replacement) and run inside the function doing the replacements.
let wrapper;
if (ctx.cmdName == "HTML") {
wrapper = new Function('return ' + context[context.__code__] + ';');
} else {
wrapper = new Function("return " + context.__code__ + ";");
}
result = await wrapper.call(context);
In processTemplate.ts I had to set the cmdName to ctx (ctx.cmdName = cmdName) before jsSandbox.ts call.
It is working very well for me but maybe are limitations or some issues I'm not having here yet.
I wanted to have opinions and feedback from the guys that developed the lib or have more experience with it. If you believe I will have any big issue in the future. Or any other alternative that the community faced with similar situation with eval.
PS. Another alternative was to put all the data inside the window global so the Eval works like intended... it worked but the window global on Salesforce has so many variables that become trash elements to the API that can end generating issues... even more because my tokens have all the Fields names of objects in the Salesforce to be easy to get it via QUERY... so if a field has the same name than a element in global window it will generate issues... I avoided taking that path.
Thanks for the amazing work in the lib.
Sorry for my bad English.
The text was updated successfully, but these errors were encountered:
Hello.
I have more a point referent at using your (amazing) lib than exactly a bug.
In Salesforce Lighting Web Component the eval function have fixed scope, that means the "this" will always be the global window and you can't change that.
That makes the 'noSandbox = false' to not work because the iframe create won't even have an eval function.
And in 'noSandbox = true' you will face the issue with the scope.
I found a solution for what I'm using that either involve INS and HTML.
For INS I used a function passing the scope.
While for HTML I got the content direct (that has the ` comenda for variable replacement) and run inside the function doing the replacements.
It is working very well for me but maybe are limitations or some issues I'm not having here yet.
I wanted to have opinions and feedback from the guys that developed the lib or have more experience with it. If you believe I will have any big issue in the future. Or any other alternative that the community faced with similar situation with eval.
PS. Another alternative was to put all the data inside the window global so the Eval works like intended... it worked but the window global on Salesforce has so many variables that become trash elements to the API that can end generating issues... even more because my tokens have all the Fields names of objects in the Salesforce to be easy to get it via QUERY... so if a field has the same name than a element in global window it will generate issues... I avoided taking that path.
Thanks for the amazing work in the lib.
Sorry for my bad English.
The text was updated successfully, but these errors were encountered: