feat: ternary
This commit is contained in:
parent
b6d6dc4766
commit
107d6964a1
|
@ -98,7 +98,6 @@ export default class Sandbox {
|
|||
console.error("evaluateAssignmentExpression(): Can't handle operator", node.operator);
|
||||
return undefined;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
if (Vasync) {
|
||||
return {
|
||||
|
@ -295,6 +294,19 @@ export default class Sandbox {
|
|||
return {value: invokeMember(O.value, P.value, args, callOptional, memberOptional)};
|
||||
}
|
||||
|
||||
evaluateConditionalExpression(node) {
|
||||
const test = this.evaluate(node.test);
|
||||
if (test.async) {
|
||||
return {
|
||||
async: true,
|
||||
value: Promise.resolve(test.value).then((test) => (
|
||||
this.evaluate(test ? node.consequent : node.alternate).value
|
||||
)),
|
||||
};
|
||||
}
|
||||
return this.evaluate(test.value ? node.consequent : node.alternate);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
evaluateDirectiveLiteral({value}) {
|
||||
return {value};
|
||||
|
@ -560,6 +572,7 @@ export default class Sandbox {
|
|||
'AwaitExpression',
|
||||
'BinaryExpression',
|
||||
'CallExpression',
|
||||
'ConditionalExpression',
|
||||
'DirectiveLiteral',
|
||||
'Identifier',
|
||||
'Literal',
|
||||
|
|
Loading…
Reference in New Issue
Block a user