@lwc/template-compiler 3.7.0 → 3.7.2
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 +191 -181
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +191 -181
- package/dist/index.js.map +1 -1
- package/dist/parser/attribute.d.ts +3 -3
- package/dist/parser/expression-complex/html.d.ts +1 -1
- package/dist/parser/expression-complex/types.d.ts +2 -2
- package/dist/shared/ast.d.ts +1 -1
- package/package.json +5 -4
- package/dist/shared/parse5.d.ts +0 -19
package/dist/index.cjs.js
CHANGED
|
@@ -182,167 +182,6 @@ function normalizeConfig(config) {
|
|
|
182
182
|
experimentalComplexExpressions: false, experimentalDynamicDirective: false, enableDynamicComponents: false, enableStaticContentOptimization: true, enableLwcSpread: true }, config), { apiVersion }), { customRendererConfig }), { instrumentation });
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
function isIdentifier(node) {
|
|
186
|
-
return node.type === 'Identifier';
|
|
187
|
-
}
|
|
188
|
-
function isMemberExpression(node) {
|
|
189
|
-
return node.type === 'MemberExpression';
|
|
190
|
-
}
|
|
191
|
-
function isArrayExpression(node) {
|
|
192
|
-
return node.type === 'ArrayExpression';
|
|
193
|
-
}
|
|
194
|
-
function isObjectExpression(node) {
|
|
195
|
-
return node.type === 'ObjectExpression';
|
|
196
|
-
}
|
|
197
|
-
function isProperty$1(node) {
|
|
198
|
-
return node.type === 'Property';
|
|
199
|
-
}
|
|
200
|
-
function isArrowFunctionExpression(node) {
|
|
201
|
-
return node.type === 'ArrowFunctionExpression';
|
|
202
|
-
}
|
|
203
|
-
function isObjectPattern(node) {
|
|
204
|
-
return node.type === 'ObjectPattern';
|
|
205
|
-
}
|
|
206
|
-
function isArrayPattern(node) {
|
|
207
|
-
return node.type === 'ArrayPattern';
|
|
208
|
-
}
|
|
209
|
-
function isRestElement(node) {
|
|
210
|
-
return node.type === 'RestElement';
|
|
211
|
-
}
|
|
212
|
-
function isAssignmentPattern(node) {
|
|
213
|
-
return node.type === 'AssigmentPattern';
|
|
214
|
-
}
|
|
215
|
-
function isUnaryExpression(node) {
|
|
216
|
-
return node.type === 'UnaryExpression';
|
|
217
|
-
}
|
|
218
|
-
function identifier(name, config) {
|
|
219
|
-
return Object.assign({ type: 'Identifier', name }, config);
|
|
220
|
-
}
|
|
221
|
-
function isLiteral(node) {
|
|
222
|
-
return node.type === 'Literal';
|
|
223
|
-
}
|
|
224
|
-
function memberExpression(object, property, config) {
|
|
225
|
-
return Object.assign({ type: 'MemberExpression', object,
|
|
226
|
-
property, computed: false, optional: false }, config);
|
|
227
|
-
}
|
|
228
|
-
function callExpression(callee, args, config) {
|
|
229
|
-
return Object.assign({ type: 'CallExpression', callee, arguments: args, optional: false }, config);
|
|
230
|
-
}
|
|
231
|
-
function literal$1(value, config) {
|
|
232
|
-
return Object.assign({ type: 'Literal', value }, config);
|
|
233
|
-
}
|
|
234
|
-
function conditionalExpression(test, consequent, alternate, config) {
|
|
235
|
-
return Object.assign({ type: 'ConditionalExpression', test,
|
|
236
|
-
consequent,
|
|
237
|
-
alternate }, config);
|
|
238
|
-
}
|
|
239
|
-
function unaryExpression(operator, argument, config) {
|
|
240
|
-
return Object.assign({ type: 'UnaryExpression', argument,
|
|
241
|
-
operator, prefix: true }, config);
|
|
242
|
-
}
|
|
243
|
-
function binaryExpression(operator, left, right, config) {
|
|
244
|
-
return Object.assign({ type: 'BinaryExpression', left,
|
|
245
|
-
operator,
|
|
246
|
-
right }, config);
|
|
247
|
-
}
|
|
248
|
-
function logicalExpression(operator, left, right, config) {
|
|
249
|
-
return Object.assign({ type: 'LogicalExpression', operator,
|
|
250
|
-
left,
|
|
251
|
-
right }, config);
|
|
252
|
-
}
|
|
253
|
-
function assignmentExpression(operator, left, right, config) {
|
|
254
|
-
return Object.assign({ type: 'AssignmentExpression', operator,
|
|
255
|
-
left,
|
|
256
|
-
right }, config);
|
|
257
|
-
}
|
|
258
|
-
function property$1(key, value, config) {
|
|
259
|
-
return Object.assign({ type: 'Property', key,
|
|
260
|
-
value, kind: 'init', computed: false, method: false, shorthand: false }, config);
|
|
261
|
-
}
|
|
262
|
-
function spreadElement(argument) {
|
|
263
|
-
return {
|
|
264
|
-
type: 'SpreadElement',
|
|
265
|
-
argument,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
function assignmentProperty(key, value, config) {
|
|
269
|
-
return Object.assign({ type: 'Property', key,
|
|
270
|
-
value, kind: 'init', computed: false, method: false, shorthand: false }, config);
|
|
271
|
-
}
|
|
272
|
-
function objectExpression(properties, config) {
|
|
273
|
-
return Object.assign({ type: 'ObjectExpression', properties }, config);
|
|
274
|
-
}
|
|
275
|
-
function objectPattern(properties, config) {
|
|
276
|
-
return Object.assign({ type: 'ObjectPattern', properties }, config);
|
|
277
|
-
}
|
|
278
|
-
function arrayExpression(elements, config) {
|
|
279
|
-
return Object.assign({ type: 'ArrayExpression', elements }, config);
|
|
280
|
-
}
|
|
281
|
-
function expressionStatement(expression, config) {
|
|
282
|
-
return Object.assign({ type: 'ExpressionStatement', expression }, config);
|
|
283
|
-
}
|
|
284
|
-
function taggedTemplateExpression(tag, quasi) {
|
|
285
|
-
return {
|
|
286
|
-
type: 'TaggedTemplateExpression',
|
|
287
|
-
tag,
|
|
288
|
-
quasi,
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function templateLiteral(quasis, expressions) {
|
|
292
|
-
return {
|
|
293
|
-
type: 'TemplateLiteral',
|
|
294
|
-
quasis,
|
|
295
|
-
expressions,
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
function functionExpression(id, params, body, config) {
|
|
299
|
-
return Object.assign({ type: 'FunctionExpression', id,
|
|
300
|
-
params,
|
|
301
|
-
body }, config);
|
|
302
|
-
}
|
|
303
|
-
function functionDeclaration(id, params, body, config) {
|
|
304
|
-
return Object.assign({ type: 'FunctionDeclaration', id,
|
|
305
|
-
params,
|
|
306
|
-
body }, config);
|
|
307
|
-
}
|
|
308
|
-
function blockStatement(body, config) {
|
|
309
|
-
return Object.assign({ type: 'BlockStatement', body }, config);
|
|
310
|
-
}
|
|
311
|
-
function returnStatement(argument, config) {
|
|
312
|
-
return Object.assign({ type: 'ReturnStatement', argument }, config);
|
|
313
|
-
}
|
|
314
|
-
function variableDeclarator(id, init, config) {
|
|
315
|
-
return Object.assign({ type: 'VariableDeclarator', id,
|
|
316
|
-
init }, config);
|
|
317
|
-
}
|
|
318
|
-
function variableDeclaration(kind, declarations, config) {
|
|
319
|
-
return Object.assign({ type: 'VariableDeclaration', kind,
|
|
320
|
-
declarations }, config);
|
|
321
|
-
}
|
|
322
|
-
function importDeclaration(specifiers, source, config) {
|
|
323
|
-
return Object.assign({ type: 'ImportDeclaration', specifiers,
|
|
324
|
-
source }, config);
|
|
325
|
-
}
|
|
326
|
-
function importDefaultSpecifier(local, config) {
|
|
327
|
-
return Object.assign({ type: 'ImportDefaultSpecifier', local }, config);
|
|
328
|
-
}
|
|
329
|
-
function importSpecifier(imported, local, config) {
|
|
330
|
-
return Object.assign({ type: 'ImportSpecifier', imported,
|
|
331
|
-
local }, config);
|
|
332
|
-
}
|
|
333
|
-
function exportDefaultDeclaration(declaration, config) {
|
|
334
|
-
return Object.assign({ type: 'ExportDefaultDeclaration', declaration }, config);
|
|
335
|
-
}
|
|
336
|
-
function program(body, config) {
|
|
337
|
-
return Object.assign({ type: 'Program', sourceType: 'module', body }, config);
|
|
338
|
-
}
|
|
339
|
-
function comment$1(content) {
|
|
340
|
-
return {
|
|
341
|
-
type: 'Block',
|
|
342
|
-
value: content,
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
|
|
346
185
|
const UNDEFINED_CODE_POINTS = new Set([
|
|
347
186
|
65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214,
|
|
348
187
|
393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894,
|
|
@@ -8746,26 +8585,189 @@ function parseFragment$1(fragmentContext, html, options) {
|
|
|
8746
8585
|
return parser.getFragment();
|
|
8747
8586
|
}
|
|
8748
8587
|
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8588
|
+
({
|
|
8589
|
+
HTML: NS.HTML,
|
|
8590
|
+
XML: NS.XML,
|
|
8591
|
+
MATHML: NS.MATHML,
|
|
8592
|
+
SVG: NS.SVG,
|
|
8593
|
+
XLINK: NS.XLINK,
|
|
8594
|
+
XMLNS: NS.XMLNS
|
|
8595
|
+
});
|
|
8596
|
+
|
|
8597
|
+
/**
|
|
8598
|
+
* Determines if a given node is a template node or not
|
|
8599
|
+
* @param {Node} node Node to test
|
|
8600
|
+
* @return {boolean}
|
|
8754
8601
|
*/
|
|
8755
|
-
function
|
|
8756
|
-
return node
|
|
8602
|
+
function isTemplateNode(node) {
|
|
8603
|
+
return node.nodeName === 'template';
|
|
8757
8604
|
}
|
|
8758
|
-
|
|
8759
|
-
|
|
8605
|
+
const isElementNode = defaultTreeAdapter.isElementNode;
|
|
8606
|
+
const isCommentNode = defaultTreeAdapter.isCommentNode;
|
|
8607
|
+
defaultTreeAdapter.isDocumentTypeNode;
|
|
8608
|
+
const isTextNode$1 = defaultTreeAdapter.isTextNode;
|
|
8609
|
+
|
|
8610
|
+
defaultTreeAdapter.appendChild;
|
|
8611
|
+
|
|
8612
|
+
function isIdentifier(node) {
|
|
8613
|
+
return node.type === 'Identifier';
|
|
8760
8614
|
}
|
|
8761
|
-
function
|
|
8762
|
-
return node.
|
|
8615
|
+
function isMemberExpression(node) {
|
|
8616
|
+
return node.type === 'MemberExpression';
|
|
8763
8617
|
}
|
|
8764
|
-
function
|
|
8765
|
-
return
|
|
8618
|
+
function isArrayExpression(node) {
|
|
8619
|
+
return node.type === 'ArrayExpression';
|
|
8620
|
+
}
|
|
8621
|
+
function isObjectExpression(node) {
|
|
8622
|
+
return node.type === 'ObjectExpression';
|
|
8623
|
+
}
|
|
8624
|
+
function isProperty$1(node) {
|
|
8625
|
+
return node.type === 'Property';
|
|
8626
|
+
}
|
|
8627
|
+
function isArrowFunctionExpression(node) {
|
|
8628
|
+
return node.type === 'ArrowFunctionExpression';
|
|
8629
|
+
}
|
|
8630
|
+
function isObjectPattern(node) {
|
|
8631
|
+
return node.type === 'ObjectPattern';
|
|
8632
|
+
}
|
|
8633
|
+
function isArrayPattern(node) {
|
|
8634
|
+
return node.type === 'ArrayPattern';
|
|
8635
|
+
}
|
|
8636
|
+
function isRestElement(node) {
|
|
8637
|
+
return node.type === 'RestElement';
|
|
8638
|
+
}
|
|
8639
|
+
function isAssignmentPattern(node) {
|
|
8640
|
+
return node.type === 'AssigmentPattern';
|
|
8641
|
+
}
|
|
8642
|
+
function isUnaryExpression(node) {
|
|
8643
|
+
return node.type === 'UnaryExpression';
|
|
8644
|
+
}
|
|
8645
|
+
function identifier(name, config) {
|
|
8646
|
+
return Object.assign({ type: 'Identifier', name }, config);
|
|
8647
|
+
}
|
|
8648
|
+
function isLiteral(node) {
|
|
8649
|
+
return node.type === 'Literal';
|
|
8650
|
+
}
|
|
8651
|
+
function memberExpression(object, property, config) {
|
|
8652
|
+
return Object.assign({ type: 'MemberExpression', object,
|
|
8653
|
+
property, computed: false, optional: false }, config);
|
|
8654
|
+
}
|
|
8655
|
+
function callExpression(callee, args, config) {
|
|
8656
|
+
return Object.assign({ type: 'CallExpression', callee, arguments: args, optional: false }, config);
|
|
8657
|
+
}
|
|
8658
|
+
function literal$1(value, config) {
|
|
8659
|
+
return Object.assign({ type: 'Literal', value }, config);
|
|
8660
|
+
}
|
|
8661
|
+
function conditionalExpression(test, consequent, alternate, config) {
|
|
8662
|
+
return Object.assign({ type: 'ConditionalExpression', test,
|
|
8663
|
+
consequent,
|
|
8664
|
+
alternate }, config);
|
|
8665
|
+
}
|
|
8666
|
+
function unaryExpression(operator, argument, config) {
|
|
8667
|
+
return Object.assign({ type: 'UnaryExpression', argument,
|
|
8668
|
+
operator, prefix: true }, config);
|
|
8669
|
+
}
|
|
8670
|
+
function binaryExpression(operator, left, right, config) {
|
|
8671
|
+
return Object.assign({ type: 'BinaryExpression', left,
|
|
8672
|
+
operator,
|
|
8673
|
+
right }, config);
|
|
8674
|
+
}
|
|
8675
|
+
function logicalExpression(operator, left, right, config) {
|
|
8676
|
+
return Object.assign({ type: 'LogicalExpression', operator,
|
|
8677
|
+
left,
|
|
8678
|
+
right }, config);
|
|
8679
|
+
}
|
|
8680
|
+
function assignmentExpression(operator, left, right, config) {
|
|
8681
|
+
return Object.assign({ type: 'AssignmentExpression', operator,
|
|
8682
|
+
left,
|
|
8683
|
+
right }, config);
|
|
8684
|
+
}
|
|
8685
|
+
function property$1(key, value, config) {
|
|
8686
|
+
return Object.assign({ type: 'Property', key,
|
|
8687
|
+
value, kind: 'init', computed: false, method: false, shorthand: false }, config);
|
|
8688
|
+
}
|
|
8689
|
+
function spreadElement(argument) {
|
|
8690
|
+
return {
|
|
8691
|
+
type: 'SpreadElement',
|
|
8692
|
+
argument,
|
|
8693
|
+
};
|
|
8694
|
+
}
|
|
8695
|
+
function assignmentProperty(key, value, config) {
|
|
8696
|
+
return Object.assign({ type: 'Property', key,
|
|
8697
|
+
value, kind: 'init', computed: false, method: false, shorthand: false }, config);
|
|
8698
|
+
}
|
|
8699
|
+
function objectExpression(properties, config) {
|
|
8700
|
+
return Object.assign({ type: 'ObjectExpression', properties }, config);
|
|
8701
|
+
}
|
|
8702
|
+
function objectPattern(properties, config) {
|
|
8703
|
+
return Object.assign({ type: 'ObjectPattern', properties }, config);
|
|
8704
|
+
}
|
|
8705
|
+
function arrayExpression(elements, config) {
|
|
8706
|
+
return Object.assign({ type: 'ArrayExpression', elements }, config);
|
|
8707
|
+
}
|
|
8708
|
+
function expressionStatement(expression, config) {
|
|
8709
|
+
return Object.assign({ type: 'ExpressionStatement', expression }, config);
|
|
8710
|
+
}
|
|
8711
|
+
function taggedTemplateExpression(tag, quasi) {
|
|
8712
|
+
return {
|
|
8713
|
+
type: 'TaggedTemplateExpression',
|
|
8714
|
+
tag,
|
|
8715
|
+
quasi,
|
|
8716
|
+
};
|
|
8717
|
+
}
|
|
8718
|
+
function templateLiteral(quasis, expressions) {
|
|
8719
|
+
return {
|
|
8720
|
+
type: 'TemplateLiteral',
|
|
8721
|
+
quasis,
|
|
8722
|
+
expressions,
|
|
8723
|
+
};
|
|
8724
|
+
}
|
|
8725
|
+
function functionExpression(id, params, body, config) {
|
|
8726
|
+
return Object.assign({ type: 'FunctionExpression', id,
|
|
8727
|
+
params,
|
|
8728
|
+
body }, config);
|
|
8729
|
+
}
|
|
8730
|
+
function functionDeclaration(id, params, body, config) {
|
|
8731
|
+
return Object.assign({ type: 'FunctionDeclaration', id,
|
|
8732
|
+
params,
|
|
8733
|
+
body }, config);
|
|
8766
8734
|
}
|
|
8767
|
-
function
|
|
8768
|
-
return
|
|
8735
|
+
function blockStatement(body, config) {
|
|
8736
|
+
return Object.assign({ type: 'BlockStatement', body }, config);
|
|
8737
|
+
}
|
|
8738
|
+
function returnStatement(argument, config) {
|
|
8739
|
+
return Object.assign({ type: 'ReturnStatement', argument }, config);
|
|
8740
|
+
}
|
|
8741
|
+
function variableDeclarator(id, init, config) {
|
|
8742
|
+
return Object.assign({ type: 'VariableDeclarator', id,
|
|
8743
|
+
init }, config);
|
|
8744
|
+
}
|
|
8745
|
+
function variableDeclaration(kind, declarations, config) {
|
|
8746
|
+
return Object.assign({ type: 'VariableDeclaration', kind,
|
|
8747
|
+
declarations }, config);
|
|
8748
|
+
}
|
|
8749
|
+
function importDeclaration(specifiers, source, config) {
|
|
8750
|
+
return Object.assign({ type: 'ImportDeclaration', specifiers,
|
|
8751
|
+
source }, config);
|
|
8752
|
+
}
|
|
8753
|
+
function importDefaultSpecifier(local, config) {
|
|
8754
|
+
return Object.assign({ type: 'ImportDefaultSpecifier', local }, config);
|
|
8755
|
+
}
|
|
8756
|
+
function importSpecifier(imported, local, config) {
|
|
8757
|
+
return Object.assign({ type: 'ImportSpecifier', imported,
|
|
8758
|
+
local }, config);
|
|
8759
|
+
}
|
|
8760
|
+
function exportDefaultDeclaration(declaration, config) {
|
|
8761
|
+
return Object.assign({ type: 'ExportDefaultDeclaration', declaration }, config);
|
|
8762
|
+
}
|
|
8763
|
+
function program(body, config) {
|
|
8764
|
+
return Object.assign({ type: 'Program', sourceType: 'module', body }, config);
|
|
8765
|
+
}
|
|
8766
|
+
function comment$1(content) {
|
|
8767
|
+
return {
|
|
8768
|
+
type: 'Block',
|
|
8769
|
+
value: content,
|
|
8770
|
+
};
|
|
8769
8771
|
}
|
|
8770
8772
|
|
|
8771
8773
|
/*
|
|
@@ -10654,7 +10656,7 @@ class TemplateHtmlParser extends Parser {
|
|
|
10654
10656
|
const textNode = {
|
|
10655
10657
|
nodeName: '#text',
|
|
10656
10658
|
value: token.chars,
|
|
10657
|
-
sourceCodeLocation: Object.assign({}, token.location),
|
|
10659
|
+
sourceCodeLocation: token.location ? Object.assign({}, token.location) : null,
|
|
10658
10660
|
parentNode,
|
|
10659
10661
|
};
|
|
10660
10662
|
parentNode.childNodes.push(textNode);
|
|
@@ -11216,7 +11218,7 @@ function parseElementLocation(ctx, parse5Elm, parse5ParentLocation) {
|
|
|
11216
11218
|
// creates a <tbody> element in the middle without location information. In this case, we
|
|
11217
11219
|
// can safely skip the closing tag validation.
|
|
11218
11220
|
let current = parse5Elm;
|
|
11219
|
-
while (!location && isElementNode(current.parentNode)) {
|
|
11221
|
+
while (!location && current.parentNode && isElementNode(current.parentNode)) {
|
|
11220
11222
|
current = current.parentNode;
|
|
11221
11223
|
location = current.sourceCodeLocation;
|
|
11222
11224
|
}
|
|
@@ -11306,7 +11308,14 @@ function parseLwcElementAsBuiltIn(ctx, parse5Elm, _parsedAttr, parse5ElmLocation
|
|
|
11306
11308
|
}
|
|
11307
11309
|
function parseChildren(ctx, parse5Parent, parent, parse5ParentLocation) {
|
|
11308
11310
|
var _a;
|
|
11309
|
-
|
|
11311
|
+
let container = parse5Parent;
|
|
11312
|
+
// `content` isn't nullable but we need to keep the optional chaining
|
|
11313
|
+
// until parse5/tools also asserts that `content` is set. It should be
|
|
11314
|
+
// impossible to have nullish `content`, but templates in SVG can cause it
|
|
11315
|
+
if (isTemplateNode(parse5Parent) && ((_a = parse5Parent.content) === null || _a === void 0 ? void 0 : _a.childNodes.length) > 0) {
|
|
11316
|
+
container = parse5Parent.content;
|
|
11317
|
+
}
|
|
11318
|
+
const children = container.childNodes;
|
|
11310
11319
|
ctx.beginSiblingScope();
|
|
11311
11320
|
for (const child of children) {
|
|
11312
11321
|
ctx.withErrorRecovery(() => {
|
|
@@ -11401,11 +11410,12 @@ function parseComment(parse5Comment) {
|
|
|
11401
11410
|
return comment(parse5Comment.data, decodeTextContent(parse5Comment.data), location);
|
|
11402
11411
|
}
|
|
11403
11412
|
function getTemplateRoot(ctx, documentFragment) {
|
|
11413
|
+
var _a;
|
|
11404
11414
|
// Filter all the empty text nodes
|
|
11405
11415
|
const validRoots = documentFragment.childNodes.filter((child) => isElementNode(child) ||
|
|
11406
11416
|
(isTextNode$1(child) && child.value.trim().length));
|
|
11407
11417
|
if (validRoots.length > 1) {
|
|
11408
|
-
const duplicateRoot = validRoots[1].sourceCodeLocation;
|
|
11418
|
+
const duplicateRoot = (_a = validRoots[1].sourceCodeLocation) !== null && _a !== void 0 ? _a : undefined;
|
|
11409
11419
|
ctx.throw(errors.ParserDiagnostics.MULTIPLE_ROOTS_FOUND, [], duplicateRoot ? sourceLocation(duplicateRoot) : duplicateRoot !== null && duplicateRoot !== void 0 ? duplicateRoot : undefined);
|
|
11410
11420
|
}
|
|
11411
11421
|
const [root] = validRoots;
|
|
@@ -13821,5 +13831,5 @@ function compile(source, config) {
|
|
|
13821
13831
|
exports.compile = compile;
|
|
13822
13832
|
exports.default = compile;
|
|
13823
13833
|
exports.parse = parse;
|
|
13824
|
-
/** version: 3.7.
|
|
13834
|
+
/** version: 3.7.2 */
|
|
13825
13835
|
//# sourceMappingURL=index.cjs.js.map
|