@lwc/template-compiler 6.2.0 → 6.2.1
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/codegen/codegen.d.ts +8 -2
- package/dist/codegen/expression.d.ts +10 -8
- package/dist/codegen/formatters/module.d.ts +2 -1
- package/dist/codegen/helpers.d.ts +3 -0
- package/dist/codegen/optimize.d.ts +1 -0
- package/dist/config.d.ts +14 -13
- package/dist/index.cjs.js +88 -38
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +88 -38
- package/dist/index.js.map +1 -1
- package/dist/parser/attribute.d.ts +1 -0
- package/dist/parser/expression-complex/html.d.ts +3 -5
- package/dist/parser/parser.d.ts +26 -8
- package/dist/shared/utils.d.ts +2 -0
- package/package.json +3 -3
|
@@ -69,10 +69,15 @@ export default class CodeGen {
|
|
|
69
69
|
genScopedFragId(id: string | t.Expression): t.CallExpression;
|
|
70
70
|
/**
|
|
71
71
|
* Generates childs vnodes when slot content is static.
|
|
72
|
+
* @param slotName
|
|
73
|
+
* @param data
|
|
74
|
+
* @param children
|
|
72
75
|
*/
|
|
73
76
|
getSlot(slotName: string, data: t.ObjectExpression, children: t.Expression): import("estree").CallExpression;
|
|
74
77
|
/**
|
|
75
78
|
* Generates a factory function that inturn generates child vnodes for scoped slot content.
|
|
79
|
+
* @param callback
|
|
80
|
+
* @param slotName
|
|
76
81
|
*/
|
|
77
82
|
getScopedSlotFactory(callback: t.FunctionExpression, slotName: t.Expression | t.SimpleLiteral): import("estree").CallExpression;
|
|
78
83
|
genTabIndex(children: [t.Expression]): import("estree").CallExpression;
|
|
@@ -84,9 +89,8 @@ export default class CodeGen {
|
|
|
84
89
|
* This routine generates an expression that avoids
|
|
85
90
|
* computing the sanitized html of a raw html if it does not change
|
|
86
91
|
* between renders.
|
|
87
|
-
*
|
|
88
92
|
* @param expr
|
|
89
|
-
* @returns
|
|
93
|
+
* @returns The generated expression
|
|
90
94
|
*/
|
|
91
95
|
genSanitizedHtmlExpr(expr: t.Expression): import("estree").ConditionalExpression | import("estree").LogicalExpression;
|
|
92
96
|
private _renderApiCall;
|
|
@@ -96,12 +100,14 @@ export default class CodeGen {
|
|
|
96
100
|
declareIdentifier(identifier: t.Identifier): void;
|
|
97
101
|
/**
|
|
98
102
|
* Searches the scopes to find an identifier with a matching name.
|
|
103
|
+
* @param identifier
|
|
99
104
|
*/
|
|
100
105
|
isLocalIdentifier(identifier: t.Identifier): boolean;
|
|
101
106
|
/**
|
|
102
107
|
* Bind the passed expression to the component instance. It applies the following transformation to the expression:
|
|
103
108
|
* - {value} --> {$cmp.value}
|
|
104
109
|
* - {value[index]} --> {$cmp.value[$cmp.index]}
|
|
110
|
+
* @param expression
|
|
105
111
|
*/
|
|
106
112
|
bindExpression(expression: Expression | Literal | ComplexExpression): t.Expression;
|
|
107
113
|
genStaticElement(element: StaticElement, slotParentName?: string): t.Expression;
|
|
@@ -4,20 +4,22 @@ import type CodeGen from './codegen';
|
|
|
4
4
|
/**
|
|
5
5
|
* Bind the passed expression to the component instance. It applies the following
|
|
6
6
|
* transformation to the expression:
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* - `{value}` --> `{$cmp.value}`
|
|
8
|
+
* - `{value[index]}` --> `{$cmp.value[$cmp.index]}`
|
|
9
|
+
* - `{foo ?? bar}` --> `{$cmp.foo ?? $cmp.bar}`
|
|
10
|
+
* - `{foo?.bar}` --> `{$cmp.foo?.bar}`
|
|
11
11
|
*
|
|
12
12
|
* However, parameter variables are not be transformed in this way. For example,
|
|
13
13
|
* the following transformations do not happen:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* - `{(foo) => foo && bar}` --> `{(foo) => $cmp.foo && $cmp.bar}`
|
|
15
|
+
* - `{(foo) => foo && bar}` --> `{($cmp.foo) => foo && $cmp.bar}`
|
|
16
|
+
* - `{(foo) => foo && bar}` --> `{($cmp.foo) => $cmp.foo && $cmp.bar}`
|
|
17
17
|
*
|
|
18
18
|
* Instead, the scopes are respected:
|
|
19
|
-
*
|
|
19
|
+
* - `{(foo) => foo && $cmp.bar}`
|
|
20
20
|
*
|
|
21
21
|
* Similar checks occur for local identifiers introduced via for:each or similar.
|
|
22
|
+
* @param expression
|
|
23
|
+
* @param codeGen
|
|
22
24
|
*/
|
|
23
25
|
export declare function bindComplexExpression(expression: ComplexExpression, codeGen: CodeGen): t.Expression;
|
|
@@ -4,7 +4,8 @@ import CodeGen from '../codegen';
|
|
|
4
4
|
* Generate an ES module AST from a template ESTree AST. The generated module imports the dependent
|
|
5
5
|
* LWC components via import statements and expose the template function via a default export
|
|
6
6
|
* statement.
|
|
7
|
-
*
|
|
7
|
+
* @param templateFn
|
|
8
|
+
* @param codeGen
|
|
8
9
|
* @example
|
|
9
10
|
* ```js
|
|
10
11
|
* import { registerTemplate } from 'lwc';
|
|
@@ -10,10 +10,13 @@ export declare function objectToAST(obj: object, valueMapper: (key: string) => t
|
|
|
10
10
|
*
|
|
11
11
|
* This function searches through the children to determine if flattening needs to occur in the runtime.
|
|
12
12
|
* Children should be flattened if they contain an iterator, a dynamic directive or a slot inside a light dom element.
|
|
13
|
+
* @param codeGen
|
|
14
|
+
* @param children
|
|
13
15
|
*/
|
|
14
16
|
export declare function shouldFlatten(codeGen: CodeGen, children: ChildNode[]): boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Returns true if the AST element or any of its descendants use an id attribute.
|
|
19
|
+
* @param node
|
|
17
20
|
*/
|
|
18
21
|
export declare function hasIdAttribute(node: Node): boolean;
|
|
19
22
|
export declare function memorizeHandler(codeGen: CodeGen, componentHandler: t.Expression, handler: t.Expression): t.Expression;
|
package/dist/config.d.ts
CHANGED
|
@@ -6,23 +6,24 @@ export interface Config {
|
|
|
6
6
|
*/
|
|
7
7
|
customRendererConfig?: CustomRendererConfig;
|
|
8
8
|
/**
|
|
9
|
-
* Enable computed member expression in the template.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Enable computed member expression in the template.
|
|
10
|
+
* @example
|
|
11
|
+
* <template>
|
|
12
|
+
* {list[0].name}
|
|
13
|
+
* </template>
|
|
13
14
|
*/
|
|
14
15
|
experimentalComputedMemberExpression?: boolean;
|
|
15
16
|
/**
|
|
16
17
|
* Enable use of (a subset of) JavaScript expressions in place of template bindings.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
18
|
+
* @example
|
|
19
|
+
* <template>
|
|
20
|
+
* <input
|
|
21
|
+
* attr={complex ?? expressions()}
|
|
22
|
+
* onchange={({ target }) => componentMethod(target.value)}
|
|
23
|
+
* >
|
|
24
|
+
* Hey there {inAustralia ? 'mate' : 'friend'}
|
|
25
|
+
* </input>
|
|
26
|
+
* </template>
|
|
26
27
|
*/
|
|
27
28
|
experimentalComplexExpressions?: boolean;
|
|
28
29
|
/**
|
package/dist/index.cjs.js
CHANGED
|
@@ -78,7 +78,7 @@ const DASHED_TAGNAME_ELEMENT_SET = new Set([
|
|
|
78
78
|
const STATIC_SAFE_DIRECTIVES = new Set(['Ref']);
|
|
79
79
|
|
|
80
80
|
/*
|
|
81
|
-
* Copyright (c)
|
|
81
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
82
82
|
* All rights reserved.
|
|
83
83
|
* SPDX-License-Identifier: MIT
|
|
84
84
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
@@ -102,6 +102,7 @@ function toPropertyName(attr) {
|
|
|
102
102
|
* Test if given tag name is a custom element.
|
|
103
103
|
* @param tagName element tag name to test
|
|
104
104
|
* @returns true if given tag name represents a custom element, false otherwise.
|
|
105
|
+
* @example isCustomElementTag("my-component") // true
|
|
105
106
|
*/
|
|
106
107
|
function isCustomElementTag(tagName) {
|
|
107
108
|
return tagName.includes('-') && !DASHED_TAGNAME_ELEMENT_SET.has(tagName);
|
|
@@ -110,6 +111,7 @@ function isCustomElementTag(tagName) {
|
|
|
110
111
|
* Test if given tag name is a custom LWC tag denoted lwc:*.
|
|
111
112
|
* @param tagName element tag name to test
|
|
112
113
|
* @returns true if given tag name represents a custom LWC tag, false otherwise.
|
|
114
|
+
* @example isLwcElementTag("my-component") // false
|
|
113
115
|
*/
|
|
114
116
|
function isLwcElementTag(tagName) {
|
|
115
117
|
return tagName.startsWith('lwc:');
|
|
@@ -10156,6 +10158,8 @@ class ParserCtx {
|
|
|
10156
10158
|
}
|
|
10157
10159
|
/**
|
|
10158
10160
|
* This method flattens the scopes into a single array for traversal.
|
|
10161
|
+
* @param element
|
|
10162
|
+
* @yields Each node in the scope and its parent.
|
|
10159
10163
|
*/
|
|
10160
10164
|
*ancestors(element) {
|
|
10161
10165
|
const ancestors = this.elementScopes.flat();
|
|
@@ -10168,11 +10172,10 @@ class ParserCtx {
|
|
|
10168
10172
|
* This method returns an iterator over ancestor nodes, starting at the parent and ending at the root node.
|
|
10169
10173
|
*
|
|
10170
10174
|
* Note: There are instances when we want to terminate the traversal early, such as searching for a ForBlock parent.
|
|
10171
|
-
*
|
|
10172
|
-
* @param
|
|
10173
|
-
* @param {function} predicate - This callback is called once for each ancestor until it finds one where predicate returns true.
|
|
10174
|
-
* @param {function} traversalCond - This callback is called after predicate and will terminate the traversal if it returns false.
|
|
10175
|
+
* @param predicate This callback is called once for each ancestor until it finds one where predicate returns true.
|
|
10176
|
+
* @param traversalCond This callback is called after predicate and will terminate the traversal if it returns false.
|
|
10175
10177
|
* traversalCond is ignored if no value is provided.
|
|
10178
|
+
* @param startNode Starting node to begin search, defaults to the tail of the current scope.
|
|
10176
10179
|
*/
|
|
10177
10180
|
findAncestor(predicate, traversalCond = () => true, startNode) {
|
|
10178
10181
|
for (const { current, parent } of this.ancestors(startNode)) {
|
|
@@ -10187,8 +10190,7 @@ class ParserCtx {
|
|
|
10187
10190
|
}
|
|
10188
10191
|
/**
|
|
10189
10192
|
* This method searchs the current scope and returns the value that satisfies the predicate.
|
|
10190
|
-
*
|
|
10191
|
-
* @param {function} predicate - This callback is called once for each sibling in the current scope
|
|
10193
|
+
* @param predicate This callback is called once for each sibling in the current scope
|
|
10192
10194
|
* until it finds one where predicate returns true.
|
|
10193
10195
|
*/
|
|
10194
10196
|
findInCurrentElementScope(predicate) {
|
|
@@ -10299,8 +10301,7 @@ class ParserCtx {
|
|
|
10299
10301
|
/**
|
|
10300
10302
|
* This method recovers from diagnostic errors that are encountered when fn is invoked.
|
|
10301
10303
|
* All other errors are considered compiler errors and can not be recovered from.
|
|
10302
|
-
*
|
|
10303
|
-
* @param fn - method to be invoked.
|
|
10304
|
+
* @param fn method to be invoked.
|
|
10304
10305
|
*/
|
|
10305
10306
|
withErrorRecovery(fn) {
|
|
10306
10307
|
try {
|
|
@@ -10337,18 +10338,28 @@ class ParserCtx {
|
|
|
10337
10338
|
}
|
|
10338
10339
|
/**
|
|
10339
10340
|
* This method throws a diagnostic error with the node's location.
|
|
10341
|
+
* @param errorInfo
|
|
10342
|
+
* @param node
|
|
10343
|
+
* @param messageArgs
|
|
10340
10344
|
*/
|
|
10341
10345
|
throwOnNode(errorInfo, node, messageArgs) {
|
|
10342
10346
|
this.throw(errorInfo, messageArgs, node.location);
|
|
10343
10347
|
}
|
|
10344
10348
|
/**
|
|
10345
10349
|
* This method throws a diagnostic error with location information.
|
|
10350
|
+
* @param errorInfo
|
|
10351
|
+
* @param location
|
|
10352
|
+
* @param messageArgs
|
|
10346
10353
|
*/
|
|
10347
10354
|
throwAtLocation(errorInfo, location, messageArgs) {
|
|
10348
10355
|
this.throw(errorInfo, messageArgs, location);
|
|
10349
10356
|
}
|
|
10350
10357
|
/**
|
|
10351
10358
|
* This method throws a diagnostic error and will immediately exit the current routine.
|
|
10359
|
+
* @param errorInfo
|
|
10360
|
+
* @param messageArgs
|
|
10361
|
+
* @param location
|
|
10362
|
+
* @throws
|
|
10352
10363
|
*/
|
|
10353
10364
|
throw(errorInfo, messageArgs, location) {
|
|
10354
10365
|
throw errors.generateCompilerError(errorInfo, {
|
|
@@ -10360,18 +10371,27 @@ class ParserCtx {
|
|
|
10360
10371
|
}
|
|
10361
10372
|
/**
|
|
10362
10373
|
* This method logs a diagnostic warning with the node's location.
|
|
10374
|
+
* @param errorInfo
|
|
10375
|
+
* @param node
|
|
10376
|
+
* @param messageArgs
|
|
10363
10377
|
*/
|
|
10364
10378
|
warnOnNode(errorInfo, node, messageArgs) {
|
|
10365
10379
|
this.warn(errorInfo, messageArgs, node.location);
|
|
10366
10380
|
}
|
|
10367
10381
|
/**
|
|
10368
10382
|
* This method logs a diagnostic warning with location information.
|
|
10383
|
+
* @param errorInfo
|
|
10384
|
+
* @param location
|
|
10385
|
+
* @param messageArgs
|
|
10369
10386
|
*/
|
|
10370
10387
|
warnAtLocation(errorInfo, location, messageArgs) {
|
|
10371
10388
|
this.warn(errorInfo, messageArgs, location);
|
|
10372
10389
|
}
|
|
10373
10390
|
/**
|
|
10374
10391
|
* This method logs a diagnostic warning and will continue execution of the current routine.
|
|
10392
|
+
* @param errorInfo
|
|
10393
|
+
* @param messageArgs
|
|
10394
|
+
* @param location
|
|
10375
10395
|
*/
|
|
10376
10396
|
warn(errorInfo, messageArgs, location) {
|
|
10377
10397
|
this.addDiagnostic(errors.generateCompilerDiagnostic(errorInfo, {
|
|
@@ -10592,22 +10612,24 @@ function getTrailingChars(str) {
|
|
|
10592
10612
|
* This function checks for "unbalanced" extraneous parentheses surrounding the expression.
|
|
10593
10613
|
*
|
|
10594
10614
|
* Examples of balanced extraneous parentheses (validation passes):
|
|
10595
|
-
*
|
|
10596
|
-
*
|
|
10597
|
-
*
|
|
10615
|
+
* - `{(foo.bar)}` <-- the MemberExpressions does not account for the surrounding parens
|
|
10616
|
+
* - `{(foo())}` <-- the CallExpression does not account for the surrounding parens
|
|
10617
|
+
* - `{((foo ?? bar)())}` <-- the CallExpression does not account for the surrounding parens
|
|
10598
10618
|
*
|
|
10599
10619
|
* Examples of unbalanced extraneous parentheses (validation fails):
|
|
10600
|
-
*
|
|
10601
|
-
*
|
|
10620
|
+
* - `{(foo.bar))}` <-- there is an extraneous trailing paren
|
|
10621
|
+
* - `{foo())}` <-- there is an extraneous trailing paren
|
|
10602
10622
|
*
|
|
10603
10623
|
* Examples of no extraneous parentheses (validation passes):
|
|
10604
|
-
*
|
|
10605
|
-
*
|
|
10606
|
-
*
|
|
10624
|
+
* - `{foo()}` <-- the CallExpression accounts for the trailing paren
|
|
10625
|
+
* - `{(foo ?? bar).baz}` <-- the outer MemberExpression accounts for the leading paren
|
|
10626
|
+
* - `{(foo).bar}` <-- the outer MemberExpression accounts for the leading paren
|
|
10607
10627
|
*
|
|
10608
10628
|
* Notably, no examples of extraneous leading parens could be found - these result in a
|
|
10609
10629
|
* parsing error in Acorn. However, this function still checks, in case there is an
|
|
10610
10630
|
* unknown expression that would parse with an extraneous leading paren.
|
|
10631
|
+
* @param leadingChars
|
|
10632
|
+
* @param trailingChars
|
|
10611
10633
|
*/
|
|
10612
10634
|
function validateMatchingExtraParens(leadingChars, trailingChars) {
|
|
10613
10635
|
const numLeadingParens = leadingChars.split('(').length - 1;
|
|
@@ -10619,8 +10641,8 @@ function validateMatchingExtraParens(leadingChars, trailingChars) {
|
|
|
10619
10641
|
*
|
|
10620
10642
|
* Its behavior diverges from that specified in the WHATWG HTML spec
|
|
10621
10643
|
* in two places:
|
|
10622
|
-
*
|
|
10623
|
-
*
|
|
10644
|
+
* - 13.2.5.38 - unquoted attribute values
|
|
10645
|
+
* - 13.2.5.1 - the "data" state, which corresponds to parsing outside of tags
|
|
10624
10646
|
*
|
|
10625
10647
|
* Specifically, this tokenizer defers to Acorn's JavaScript parser when
|
|
10626
10648
|
* encountering a `{` character for an attribute value or within a text
|
|
@@ -10771,11 +10793,9 @@ class TemplateHtmlParser extends Parser {
|
|
|
10771
10793
|
/**
|
|
10772
10794
|
* Parse the LWC template using a customized parser & lexer that allow
|
|
10773
10795
|
* for template expressions to be parsed correctly.
|
|
10774
|
-
*
|
|
10775
|
-
* @param
|
|
10776
|
-
* @
|
|
10777
|
-
*
|
|
10778
|
-
* @return {DocumentFragment} the parsed document
|
|
10796
|
+
* @param source raw template markup
|
|
10797
|
+
* @param config
|
|
10798
|
+
* @returns the parsed document
|
|
10779
10799
|
*/
|
|
10780
10800
|
function parseFragment(source, config) {
|
|
10781
10801
|
const { ctx, sourceCodeLocationInfo = true, onParseError } = config;
|
|
@@ -11155,6 +11175,7 @@ function isTemplateDirective(attrName) {
|
|
|
11155
11175
|
}
|
|
11156
11176
|
/**
|
|
11157
11177
|
* Convert attribute name from kebab case to camel case property name
|
|
11178
|
+
* @param attrName
|
|
11158
11179
|
*/
|
|
11159
11180
|
function attributeToPropertyName(attrName) {
|
|
11160
11181
|
return ATTRS_PROPS_TRANFORMS[attrName] || toPropertyName(attrName);
|
|
@@ -11283,6 +11304,10 @@ function parseRoot(ctx, parse5Elm) {
|
|
|
11283
11304
|
*
|
|
11284
11305
|
* Note: Not every node in the hierarchy is guaranteed to be created, for example,
|
|
11285
11306
|
* <div></div> will only create an Element node.
|
|
11307
|
+
* @param ctx
|
|
11308
|
+
* @param parse5Elm
|
|
11309
|
+
* @param parentNode
|
|
11310
|
+
* @param parse5ParentLocation
|
|
11286
11311
|
*/
|
|
11287
11312
|
function parseElement(ctx, parse5Elm, parentNode, parse5ParentLocation) {
|
|
11288
11313
|
const parse5ElmLocation = parseElementLocation(ctx, parse5Elm, parse5ParentLocation);
|
|
@@ -12434,6 +12459,8 @@ function objectToAST(obj, valueMapper) {
|
|
|
12434
12459
|
*
|
|
12435
12460
|
* This function searches through the children to determine if flattening needs to occur in the runtime.
|
|
12436
12461
|
* Children should be flattened if they contain an iterator, a dynamic directive or a slot inside a light dom element.
|
|
12462
|
+
* @param codeGen
|
|
12463
|
+
* @param children
|
|
12437
12464
|
*/
|
|
12438
12465
|
function shouldFlatten(codeGen, children) {
|
|
12439
12466
|
return children.some((child) => {
|
|
@@ -12451,6 +12478,7 @@ function shouldFlatten(codeGen, children) {
|
|
|
12451
12478
|
}
|
|
12452
12479
|
/**
|
|
12453
12480
|
* Returns true if the AST element or any of its descendants use an id attribute.
|
|
12481
|
+
* @param node
|
|
12454
12482
|
*/
|
|
12455
12483
|
function hasIdAttribute(node) {
|
|
12456
12484
|
if (isBaseElement(node)) {
|
|
@@ -12625,6 +12653,7 @@ const rawContentElements = new Set([
|
|
|
12625
12653
|
/**
|
|
12626
12654
|
* Escape all the characters that could break a JavaScript template string literal: "`" (backtick),
|
|
12627
12655
|
* "${" (dollar + open curly) and "\" (backslash).
|
|
12656
|
+
* @param str
|
|
12628
12657
|
*/
|
|
12629
12658
|
function templateStringEscape(str) {
|
|
12630
12659
|
return str.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${');
|
|
@@ -12730,21 +12759,23 @@ function serializeStaticElement(element, preserveComments) {
|
|
|
12730
12759
|
/**
|
|
12731
12760
|
* Bind the passed expression to the component instance. It applies the following
|
|
12732
12761
|
* transformation to the expression:
|
|
12733
|
-
*
|
|
12734
|
-
*
|
|
12735
|
-
*
|
|
12736
|
-
*
|
|
12762
|
+
* - `{value}` --> `{$cmp.value}`
|
|
12763
|
+
* - `{value[index]}` --> `{$cmp.value[$cmp.index]}`
|
|
12764
|
+
* - `{foo ?? bar}` --> `{$cmp.foo ?? $cmp.bar}`
|
|
12765
|
+
* - `{foo?.bar}` --> `{$cmp.foo?.bar}`
|
|
12737
12766
|
*
|
|
12738
12767
|
* However, parameter variables are not be transformed in this way. For example,
|
|
12739
12768
|
* the following transformations do not happen:
|
|
12740
|
-
*
|
|
12741
|
-
*
|
|
12742
|
-
*
|
|
12769
|
+
* - `{(foo) => foo && bar}` --> `{(foo) => $cmp.foo && $cmp.bar}`
|
|
12770
|
+
* - `{(foo) => foo && bar}` --> `{($cmp.foo) => foo && $cmp.bar}`
|
|
12771
|
+
* - `{(foo) => foo && bar}` --> `{($cmp.foo) => $cmp.foo && $cmp.bar}`
|
|
12743
12772
|
*
|
|
12744
12773
|
* Instead, the scopes are respected:
|
|
12745
|
-
*
|
|
12774
|
+
* - `{(foo) => foo && $cmp.bar}`
|
|
12746
12775
|
*
|
|
12747
12776
|
* Similar checks occur for local identifiers introduced via for:each or similar.
|
|
12777
|
+
* @param expression
|
|
12778
|
+
* @param codeGen
|
|
12748
12779
|
*/
|
|
12749
12780
|
function bindComplexExpression(expression, codeGen) {
|
|
12750
12781
|
const expressionScopes = new ExpressionScopes();
|
|
@@ -13008,6 +13039,9 @@ class CodeGen {
|
|
|
13008
13039
|
}
|
|
13009
13040
|
/**
|
|
13010
13041
|
* Generates childs vnodes when slot content is static.
|
|
13042
|
+
* @param slotName
|
|
13043
|
+
* @param data
|
|
13044
|
+
* @param children
|
|
13011
13045
|
*/
|
|
13012
13046
|
getSlot(slotName, data, children) {
|
|
13013
13047
|
this.slotNames.add(slotName);
|
|
@@ -13020,6 +13054,8 @@ class CodeGen {
|
|
|
13020
13054
|
}
|
|
13021
13055
|
/**
|
|
13022
13056
|
* Generates a factory function that inturn generates child vnodes for scoped slot content.
|
|
13057
|
+
* @param callback
|
|
13058
|
+
* @param slotName
|
|
13023
13059
|
*/
|
|
13024
13060
|
getScopedSlotFactory(callback, slotName) {
|
|
13025
13061
|
return this._renderApiCall(RENDER_APIS.scopedSlotFactory, [slotName, callback]);
|
|
@@ -13053,9 +13089,8 @@ class CodeGen {
|
|
|
13053
13089
|
* This routine generates an expression that avoids
|
|
13054
13090
|
* computing the sanitized html of a raw html if it does not change
|
|
13055
13091
|
* between renders.
|
|
13056
|
-
*
|
|
13057
13092
|
* @param expr
|
|
13058
|
-
* @returns
|
|
13093
|
+
* @returns The generated expression
|
|
13059
13094
|
*/
|
|
13060
13095
|
genSanitizedHtmlExpr(expr) {
|
|
13061
13096
|
const instance = this.innerHtmlInstances++;
|
|
@@ -13105,6 +13140,7 @@ class CodeGen {
|
|
|
13105
13140
|
}
|
|
13106
13141
|
/**
|
|
13107
13142
|
* Searches the scopes to find an identifier with a matching name.
|
|
13143
|
+
* @param identifier
|
|
13108
13144
|
*/
|
|
13109
13145
|
isLocalIdentifier(identifier) {
|
|
13110
13146
|
let scope = this.scope;
|
|
@@ -13120,6 +13156,7 @@ class CodeGen {
|
|
|
13120
13156
|
* Bind the passed expression to the component instance. It applies the following transformation to the expression:
|
|
13121
13157
|
* - {value} --> {$cmp.value}
|
|
13122
13158
|
* - {value[index]} --> {$cmp.value[$cmp.index]}
|
|
13159
|
+
* @param expression
|
|
13123
13160
|
*/
|
|
13124
13161
|
bindExpression(expression) {
|
|
13125
13162
|
if (isIdentifier(expression)) {
|
|
@@ -13301,6 +13338,7 @@ function kebabcaseToCamelcase(name) {
|
|
|
13301
13338
|
* };
|
|
13302
13339
|
* }
|
|
13303
13340
|
* ```
|
|
13341
|
+
* @param templateFn
|
|
13304
13342
|
*/
|
|
13305
13343
|
function optimizeStaticExpressions(templateFn) {
|
|
13306
13344
|
const result = [];
|
|
@@ -13383,7 +13421,8 @@ function generateHoistedNodes(codegen) {
|
|
|
13383
13421
|
* Generate an ES module AST from a template ESTree AST. The generated module imports the dependent
|
|
13384
13422
|
* LWC components via import statements and expose the template function via a default export
|
|
13385
13423
|
* statement.
|
|
13386
|
-
*
|
|
13424
|
+
* @param templateFn
|
|
13425
|
+
* @param codeGen
|
|
13387
13426
|
* @example
|
|
13388
13427
|
* ```js
|
|
13389
13428
|
* import { registerTemplate } from 'lwc';
|
|
@@ -13562,7 +13601,6 @@ function transform(codeGen) {
|
|
|
13562
13601
|
}
|
|
13563
13602
|
/**
|
|
13564
13603
|
* Transforms an IfBlock or ElseifBlock along with both its direct descendants and its 'else' descendants.
|
|
13565
|
-
*
|
|
13566
13604
|
* @param conditionalParentBlock The IfBlock or ElseifBlock to transform into a conditional expression
|
|
13567
13605
|
* @param key The key to use for this chain of IfBlock/ElseifBlock branches, if applicable
|
|
13568
13606
|
* @returns A conditional expression representing the full conditional tree with conditionalParentBlock as the root node
|
|
@@ -13930,16 +13968,28 @@ function generate (root, state) {
|
|
|
13930
13968
|
}
|
|
13931
13969
|
|
|
13932
13970
|
/*
|
|
13933
|
-
* Copyright (c)
|
|
13971
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
13934
13972
|
* All rights reserved.
|
|
13935
13973
|
* SPDX-License-Identifier: MIT
|
|
13936
13974
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
13937
13975
|
*/
|
|
13976
|
+
/**
|
|
13977
|
+
* Parses HTML markup into an AST
|
|
13978
|
+
* @param source HTML markup to parse
|
|
13979
|
+
* @param config HTML template compilation config
|
|
13980
|
+
* @returns Object containing the AST
|
|
13981
|
+
*/
|
|
13938
13982
|
function parse(source, config = {}) {
|
|
13939
13983
|
const options = normalizeConfig(config);
|
|
13940
13984
|
const state = new State$1(options);
|
|
13941
13985
|
return parse$1(source, state);
|
|
13942
13986
|
}
|
|
13987
|
+
/**
|
|
13988
|
+
* Compiles a LWC template to JavaScript source code consumable by the engine.
|
|
13989
|
+
* @param source HTML markup to compile
|
|
13990
|
+
* @param config HTML template compilation config
|
|
13991
|
+
* @returns Object containing the compiled code and any warnings that occurred.
|
|
13992
|
+
*/
|
|
13943
13993
|
function compile(source, config) {
|
|
13944
13994
|
const options = normalizeConfig(config);
|
|
13945
13995
|
const state = new State$1(options);
|
|
@@ -13970,5 +14020,5 @@ function compile(source, config) {
|
|
|
13970
14020
|
exports.compile = compile;
|
|
13971
14021
|
exports.default = compile;
|
|
13972
14022
|
exports.parse = parse;
|
|
13973
|
-
/** version: 6.2.
|
|
14023
|
+
/** version: 6.2.1 */
|
|
13974
14024
|
//# sourceMappingURL=index.cjs.js.map
|