* Validate a non-prefixed expression. * This is only called when using the in-browser runtime compiler since it * doesn't prefix expressions.
(node, context, asParams = false, asRawStatements = false)
| 12765 | * doesn't prefix expressions. |
| 12766 | */ |
| 12767 | function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) { |
| 12768 | const exp = node.content; |
| 12769 | // empty expressions are validated per-directive since some directives |
| 12770 | // do allow empty expressions. |
| 12771 | if (!exp.trim()) { |
| 12772 | return; |
| 12773 | } |
| 12774 | try { |
| 12775 | new Function(asRawStatements |
| 12776 | ? ` ${exp} ` |
| 12777 | : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`); |
| 12778 | } |
| 12779 | catch (e) { |
| 12780 | let message = e.message; |
| 12781 | const keywordMatch = exp |
| 12782 | .replace(stripStringRE, '') |
| 12783 | .match(prohibitedKeywordRE); |
| 12784 | if (keywordMatch) { |
| 12785 | message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`; |
| 12786 | } |
| 12787 | context.onError(createCompilerError(43 /* X_INVALID_EXPRESSION */, node.loc, undefined, message)); |
| 12788 | } |
| 12789 | } |
| 12790 | |
| 12791 | const transformExpression = (node, context) => { |
| 12792 | if (node.type === 5 /* INTERPOLATION */) { |
no test coverage detected
searching dependent graphs…