(exp: ExpressionNode)
| 401 | // run JSFuck in here. But we mark it unsafe for security review purposes. |
| 402 | // (see compiler-core/src/transforms/transformExpression) |
| 403 | function evaluateConstant(exp: ExpressionNode): string { |
| 404 | if (exp.type === NodeTypes.SIMPLE_EXPRESSION) { |
| 405 | return new Function(`return (${exp.content})`)() |
| 406 | } else { |
| 407 | // compound |
| 408 | let res = `` |
| 409 | exp.children.forEach(c => { |
| 410 | if (isString(c) || isSymbol(c)) { |
| 411 | return |
| 412 | } |
| 413 | if (c.type === NodeTypes.TEXT) { |
| 414 | res += c.content |
| 415 | } else if (c.type === NodeTypes.INTERPOLATION) { |
| 416 | res += toDisplayString(evaluateConstant(c.content)) |
| 417 | } else { |
| 418 | res += evaluateConstant(c as ExpressionNode) |
| 419 | } |
| 420 | }) |
| 421 | return res |
| 422 | } |
| 423 | } |
no test coverage detected