@lwc/template-compiler 6.3.2 → 6.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +31 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/parser/expression-complex/types.d.ts +4 -1
- package/dist/parser/expression.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10661,7 +10661,10 @@ class TemplateHtmlTokenizer extends Tokenizer {
|
|
|
10661
10661
|
invariant(html.codePointAt(idxOfClosingBracket) === CLOSING_CURLY_BRACKET, ParserDiagnostics.TEMPLATE_EXPRESSION_PARSING_ERROR, ['expression must end with curly brace.']);
|
|
10662
10662
|
// Parsed expressions that are cached here will be later retrieved when the
|
|
10663
10663
|
// LWC template AST is being constructed.
|
|
10664
|
-
this.parser.preparsedJsExpressions.set(expressionStart,
|
|
10664
|
+
this.parser.preparsedJsExpressions.set(expressionStart, {
|
|
10665
|
+
parsedExpression: estreeNode,
|
|
10666
|
+
rawText: expressionTextNodeValue,
|
|
10667
|
+
});
|
|
10665
10668
|
return expressionTextNodeValue;
|
|
10666
10669
|
}
|
|
10667
10670
|
// ATTRIBUTE_VALUE_UNQUOTED_STATE is entered when an opening tag is being parsed,
|
|
@@ -10954,6 +10957,22 @@ function validateSourceIsParsedExpression(source, parsedExpression) {
|
|
|
10954
10957
|
'Unexpected end of expression',
|
|
10955
10958
|
]);
|
|
10956
10959
|
}
|
|
10960
|
+
function validatePreparsedJsExpressions(ctx) {
|
|
10961
|
+
ctx.preparsedJsExpressions?.forEach(({ parsedExpression, rawText }) => {
|
|
10962
|
+
const acornLoc = parsedExpression.loc;
|
|
10963
|
+
const parse5Loc = {
|
|
10964
|
+
startLine: acornLoc.start.line,
|
|
10965
|
+
startCol: acornLoc.start.column,
|
|
10966
|
+
startOffset: parsedExpression.start,
|
|
10967
|
+
endLine: acornLoc.end.line,
|
|
10968
|
+
endCol: acornLoc.end.column,
|
|
10969
|
+
endOffset: parsedExpression.end,
|
|
10970
|
+
};
|
|
10971
|
+
ctx.withErrorWrapping(() => {
|
|
10972
|
+
validateExpressionAst(parsedExpression);
|
|
10973
|
+
}, ParserDiagnostics.TEMPLATE_EXPRESSION_PARSING_ERROR, sourceLocation(parse5Loc), (err) => `Invalid expression ${rawText} - ${err.message}`);
|
|
10974
|
+
});
|
|
10975
|
+
}
|
|
10957
10976
|
function parseExpression(ctx, source, location) {
|
|
10958
10977
|
const { ecmaVersion } = ctx;
|
|
10959
10978
|
return ctx.withErrorWrapping(() => {
|
|
@@ -11241,6 +11260,7 @@ function parse$1(source, state) {
|
|
|
11241
11260
|
return { warnings: ctx.warnings };
|
|
11242
11261
|
}
|
|
11243
11262
|
const root = ctx.withErrorRecovery(() => {
|
|
11263
|
+
validatePreparsedJsExpressions(ctx);
|
|
11244
11264
|
const templateRoot = getTemplateRoot(ctx, fragment);
|
|
11245
11265
|
return parseRoot(ctx, templateRoot);
|
|
11246
11266
|
});
|
|
@@ -11503,12 +11523,12 @@ function parseText(ctx, parse5Text) {
|
|
|
11503
11523
|
// Implementation of the lexer ensures that each text-node template expression
|
|
11504
11524
|
// will be contained in its own text node. Adjacent static text will be in
|
|
11505
11525
|
// separate text nodes.
|
|
11506
|
-
const
|
|
11507
|
-
if (!
|
|
11526
|
+
const entry = ctx.preparsedJsExpressions.get(location.startOffset);
|
|
11527
|
+
if (!entry?.parsedExpression) {
|
|
11508
11528
|
throw new Error('Implementation error: cannot find preparsed template expression');
|
|
11509
11529
|
}
|
|
11510
11530
|
const value = {
|
|
11511
|
-
...
|
|
11531
|
+
...entry.parsedExpression,
|
|
11512
11532
|
location: sourceLocation(location),
|
|
11513
11533
|
};
|
|
11514
11534
|
return [text(rawText, value, location)];
|
|
@@ -12781,13 +12801,13 @@ function bindComplexExpression(expression, codeGen) {
|
|
|
12781
12801
|
},
|
|
12782
12802
|
leave(node, parent) {
|
|
12783
12803
|
if (isArrowFunctionExpression(node)) {
|
|
12784
|
-
expressionScopes.exitScope(node);
|
|
12804
|
+
return expressionScopes.exitScope(node);
|
|
12785
12805
|
}
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
!(isMemberExpression(parent) && parent.property === node) &&
|
|
12806
|
+
// Acorn parses `undefined` as an Identifier.
|
|
12807
|
+
const isIdentifier$1 = isIdentifier(node) && node.name !== 'undefined';
|
|
12808
|
+
if (parent !== null &&
|
|
12809
|
+
isIdentifier$1 &&
|
|
12810
|
+
!(isMemberExpression(parent) && parent.property === node && !parent.computed) &&
|
|
12791
12811
|
!(isProperty$1(parent) && parent.key === node) &&
|
|
12792
12812
|
!codeGen.isLocalIdentifier(node) &&
|
|
12793
12813
|
!expressionScopes.isScopedToExpression(node)) {
|
|
@@ -14013,5 +14033,5 @@ function compile(source, config) {
|
|
|
14013
14033
|
}
|
|
14014
14034
|
|
|
14015
14035
|
export { ElementDirectiveName, LWCDirectiveDomMode, LWCDirectiveRenderMode, LwcTagName, RootDirectiveName, TemplateDirectiveName, compile, compile as default, parse };
|
|
14016
|
-
/** version: 6.3.
|
|
14036
|
+
/** version: 6.3.3 */
|
|
14017
14037
|
//# sourceMappingURL=index.js.map
|