MCPcopy
hub / github.com/microsoft/playwright / validateBrowserExpression

Function validateBrowserExpression

tests/assets/reading-list/vue_3.1.5.js:12767–12789  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 */) {

Callers 4

processExpressionFunction · 0.85
processIfFunction · 0.85
parseForExpressionFunction · 0.85
transformOnFunction · 0.85

Calls 2

createCompilerErrorFunction · 0.85
onErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…