Skip to content

Commit

Permalink
[js] Fix evalling js code at runtime in the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Mar 4, 2019
1 parent 374e9fd commit 89587e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vm/js/nqp-runtime/core.js
Expand Up @@ -861,15 +861,15 @@ exports.buildSourceMap = new BuildSourceMap();

class JavaScriptCompiler extends NQPObject {
$$mangleCode(code) {
if ('/*async*/' === 'async') {
if ('/*async*/' !== '/*asy' + 'nc*/') {
return code.replace(/\/\*async\*\//g, 'async').replace(/\/\*await\*\//g, 'await');
} else {
return code;
}
}

/*async*/ p6$eval(ctx, _NAMED, self, code) {
if (!(_NAMED !== null && _NAMED.hasOwnProperty('mapping'))) {
if (process.browser || !(_NAMED !== null && _NAMED.hasOwnProperty('mapping'))) {
const codeStr = this.$$mangleCode(/*await*/ nqp.arg_s(ctx, code));
return fromJSToReturnValue(ctx, /*await*/ eval('(function() {' + codeStr + '})()'));
}
Expand Down

0 comments on commit 89587e5

Please sign in to comment.