@lwc/template-compiler 6.1.1 → 6.2.0

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 CHANGED
@@ -40,7 +40,6 @@ var astring__namespace = /*#__PURE__*/_interopNamespaceDefault(astring);
40
40
  */
41
41
  let State$1 = class State {
42
42
  constructor(config) {
43
- var _a;
44
43
  this.config = config;
45
44
  this.crElmToConfigMap = config.customRendererConfig
46
45
  ? Object.fromEntries(config.customRendererConfig.elements.map((element) => {
@@ -48,7 +47,7 @@ let State$1 = class State {
48
47
  return [tagName, { namespace, attributes: new Set(attributes) }];
49
48
  }))
50
49
  : {};
51
- this.crDirectives = new Set((_a = config.customRendererConfig) === null || _a === void 0 ? void 0 : _a.directives);
50
+ this.crDirectives = new Set(config.customRendererConfig?.directives);
52
51
  this.crCheckedElements = new Map();
53
52
  }
54
53
  };
@@ -139,7 +138,6 @@ function normalizeCustomRendererConfig(config) {
139
138
  const tagNames = [];
140
139
  const normalizedConfig = {
141
140
  elements: config.elements.map((e) => {
142
- var _a, _b;
143
141
  const tagName = e.tagName.toLowerCase();
144
142
  // Custom element cannot be allowed to have a custom renderer hook
145
143
  // The renderer is cascaded down from the owner(custom element) to all its child nodes who
@@ -150,8 +148,8 @@ function normalizeCustomRendererConfig(config) {
150
148
  tagNames.push(tagName);
151
149
  return {
152
150
  tagName,
153
- namespace: (_a = e.namespace) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
154
- attributes: (_b = e.attributes) === null || _b === void 0 ? void 0 : _b.map((a) => a.toLowerCase()),
151
+ namespace: e.namespace?.toLowerCase(),
152
+ attributes: e.attributes?.map((a) => a.toLowerCase()),
155
153
  };
156
154
  }),
157
155
  directives: config.directives.map((d) => d.toLowerCase()),
@@ -177,9 +175,20 @@ function normalizeConfig(config) {
177
175
  }
178
176
  }
179
177
  const apiVersion = shared.getAPIVersionFromNumber(config.apiVersion);
180
- return Object.assign(Object.assign(Object.assign(Object.assign({ preserveHtmlComments: false, experimentalComputedMemberExpression: false,
178
+ return {
179
+ preserveHtmlComments: false,
180
+ experimentalComputedMemberExpression: false,
181
181
  // TODO [#3370]: remove experimental template expression flag
182
- experimentalComplexExpressions: false, experimentalDynamicDirective: false, enableDynamicComponents: false, enableStaticContentOptimization: true, enableLwcSpread: true }, config), { apiVersion }), { customRendererConfig }), { instrumentation });
182
+ experimentalComplexExpressions: false,
183
+ experimentalDynamicDirective: false,
184
+ enableDynamicComponents: false,
185
+ enableStaticContentOptimization: true,
186
+ enableLwcSpread: true,
187
+ ...config,
188
+ apiVersion, // overrides the config apiVersion
189
+ ...{ customRendererConfig },
190
+ ...{ instrumentation },
191
+ };
183
192
  }
184
193
 
185
194
  const UNDEFINED_CODE_POINTS = new Set([
@@ -8643,48 +8652,97 @@ function isUnaryExpression(node) {
8643
8652
  return node.type === 'UnaryExpression';
8644
8653
  }
8645
8654
  function identifier(name, config) {
8646
- return Object.assign({ type: 'Identifier', name }, config);
8655
+ return {
8656
+ type: 'Identifier',
8657
+ name,
8658
+ ...config,
8659
+ };
8647
8660
  }
8648
8661
  function isLiteral(node) {
8649
8662
  return node.type === 'Literal';
8650
8663
  }
8651
8664
  function memberExpression(object, property, config) {
8652
- return Object.assign({ type: 'MemberExpression', object,
8653
- property, computed: false, optional: false }, config);
8665
+ return {
8666
+ type: 'MemberExpression',
8667
+ object,
8668
+ property,
8669
+ computed: false,
8670
+ optional: false,
8671
+ ...config,
8672
+ };
8654
8673
  }
8655
8674
  function callExpression(callee, args, config) {
8656
- return Object.assign({ type: 'CallExpression', callee, arguments: args, optional: false }, config);
8675
+ return {
8676
+ type: 'CallExpression',
8677
+ callee,
8678
+ arguments: args,
8679
+ optional: false,
8680
+ ...config,
8681
+ };
8657
8682
  }
8658
8683
  function literal$1(value, config) {
8659
- return Object.assign({ type: 'Literal', value }, config);
8684
+ return {
8685
+ type: 'Literal',
8686
+ value,
8687
+ ...config,
8688
+ };
8660
8689
  }
8661
8690
  function conditionalExpression(test, consequent, alternate, config) {
8662
- return Object.assign({ type: 'ConditionalExpression', test,
8691
+ return {
8692
+ type: 'ConditionalExpression',
8693
+ test,
8663
8694
  consequent,
8664
- alternate }, config);
8695
+ alternate,
8696
+ ...config,
8697
+ };
8665
8698
  }
8666
8699
  function unaryExpression(operator, argument, config) {
8667
- return Object.assign({ type: 'UnaryExpression', argument,
8668
- operator, prefix: true }, config);
8700
+ return {
8701
+ type: 'UnaryExpression',
8702
+ argument,
8703
+ operator,
8704
+ prefix: true,
8705
+ ...config,
8706
+ };
8669
8707
  }
8670
8708
  function binaryExpression(operator, left, right, config) {
8671
- return Object.assign({ type: 'BinaryExpression', left,
8709
+ return {
8710
+ type: 'BinaryExpression',
8711
+ left,
8672
8712
  operator,
8673
- right }, config);
8713
+ right,
8714
+ ...config,
8715
+ };
8674
8716
  }
8675
8717
  function logicalExpression(operator, left, right, config) {
8676
- return Object.assign({ type: 'LogicalExpression', operator,
8718
+ return {
8719
+ type: 'LogicalExpression',
8720
+ operator,
8677
8721
  left,
8678
- right }, config);
8722
+ right,
8723
+ ...config,
8724
+ };
8679
8725
  }
8680
8726
  function assignmentExpression(operator, left, right, config) {
8681
- return Object.assign({ type: 'AssignmentExpression', operator,
8727
+ return {
8728
+ type: 'AssignmentExpression',
8729
+ operator,
8682
8730
  left,
8683
- right }, config);
8731
+ right,
8732
+ ...config,
8733
+ };
8684
8734
  }
8685
8735
  function property$1(key, value, config) {
8686
- return Object.assign({ type: 'Property', key,
8687
- value, kind: 'init', computed: false, method: false, shorthand: false }, config);
8736
+ return {
8737
+ type: 'Property',
8738
+ key,
8739
+ value,
8740
+ kind: 'init',
8741
+ computed: false,
8742
+ method: false,
8743
+ shorthand: false,
8744
+ ...config,
8745
+ };
8688
8746
  }
8689
8747
  function spreadElement(argument) {
8690
8748
  return {
@@ -8693,20 +8751,44 @@ function spreadElement(argument) {
8693
8751
  };
8694
8752
  }
8695
8753
  function assignmentProperty(key, value, config) {
8696
- return Object.assign({ type: 'Property', key,
8697
- value, kind: 'init', computed: false, method: false, shorthand: false }, config);
8754
+ return {
8755
+ type: 'Property',
8756
+ key,
8757
+ value,
8758
+ kind: 'init',
8759
+ computed: false,
8760
+ method: false,
8761
+ shorthand: false,
8762
+ ...config,
8763
+ };
8698
8764
  }
8699
8765
  function objectExpression(properties, config) {
8700
- return Object.assign({ type: 'ObjectExpression', properties }, config);
8766
+ return {
8767
+ type: 'ObjectExpression',
8768
+ properties,
8769
+ ...config,
8770
+ };
8701
8771
  }
8702
8772
  function objectPattern(properties, config) {
8703
- return Object.assign({ type: 'ObjectPattern', properties }, config);
8773
+ return {
8774
+ type: 'ObjectPattern',
8775
+ properties,
8776
+ ...config,
8777
+ };
8704
8778
  }
8705
8779
  function arrayExpression(elements, config) {
8706
- return Object.assign({ type: 'ArrayExpression', elements }, config);
8780
+ return {
8781
+ type: 'ArrayExpression',
8782
+ elements,
8783
+ ...config,
8784
+ };
8707
8785
  }
8708
8786
  function expressionStatement(expression, config) {
8709
- return Object.assign({ type: 'ExpressionStatement', expression }, config);
8787
+ return {
8788
+ type: 'ExpressionStatement',
8789
+ expression,
8790
+ ...config,
8791
+ };
8710
8792
  }
8711
8793
  function taggedTemplateExpression(tag, quasi) {
8712
8794
  return {
@@ -8723,45 +8805,90 @@ function templateLiteral(quasis, expressions) {
8723
8805
  };
8724
8806
  }
8725
8807
  function functionExpression(id, params, body, config) {
8726
- return Object.assign({ type: 'FunctionExpression', id,
8808
+ return {
8809
+ type: 'FunctionExpression',
8810
+ id,
8727
8811
  params,
8728
- body }, config);
8812
+ body,
8813
+ ...config,
8814
+ };
8729
8815
  }
8730
8816
  function functionDeclaration(id, params, body, config) {
8731
- return Object.assign({ type: 'FunctionDeclaration', id,
8817
+ return {
8818
+ type: 'FunctionDeclaration',
8819
+ id,
8732
8820
  params,
8733
- body }, config);
8821
+ body,
8822
+ ...config,
8823
+ };
8734
8824
  }
8735
8825
  function blockStatement(body, config) {
8736
- return Object.assign({ type: 'BlockStatement', body }, config);
8826
+ return {
8827
+ type: 'BlockStatement',
8828
+ body,
8829
+ ...config,
8830
+ };
8737
8831
  }
8738
8832
  function returnStatement(argument, config) {
8739
- return Object.assign({ type: 'ReturnStatement', argument }, config);
8833
+ return {
8834
+ type: 'ReturnStatement',
8835
+ argument,
8836
+ ...config,
8837
+ };
8740
8838
  }
8741
8839
  function variableDeclarator(id, init, config) {
8742
- return Object.assign({ type: 'VariableDeclarator', id,
8743
- init }, config);
8840
+ return {
8841
+ type: 'VariableDeclarator',
8842
+ id,
8843
+ init,
8844
+ ...config,
8845
+ };
8744
8846
  }
8745
8847
  function variableDeclaration(kind, declarations, config) {
8746
- return Object.assign({ type: 'VariableDeclaration', kind,
8747
- declarations }, config);
8848
+ return {
8849
+ type: 'VariableDeclaration',
8850
+ kind,
8851
+ declarations,
8852
+ ...config,
8853
+ };
8748
8854
  }
8749
8855
  function importDeclaration(specifiers, source, config) {
8750
- return Object.assign({ type: 'ImportDeclaration', specifiers,
8751
- source }, config);
8856
+ return {
8857
+ type: 'ImportDeclaration',
8858
+ specifiers,
8859
+ source,
8860
+ ...config,
8861
+ };
8752
8862
  }
8753
8863
  function importDefaultSpecifier(local, config) {
8754
- return Object.assign({ type: 'ImportDefaultSpecifier', local }, config);
8864
+ return {
8865
+ type: 'ImportDefaultSpecifier',
8866
+ local,
8867
+ ...config,
8868
+ };
8755
8869
  }
8756
8870
  function importSpecifier(imported, local, config) {
8757
- return Object.assign({ type: 'ImportSpecifier', imported,
8758
- local }, config);
8871
+ return {
8872
+ type: 'ImportSpecifier',
8873
+ imported,
8874
+ local,
8875
+ ...config,
8876
+ };
8759
8877
  }
8760
8878
  function exportDefaultDeclaration(declaration, config) {
8761
- return Object.assign({ type: 'ExportDefaultDeclaration', declaration }, config);
8879
+ return {
8880
+ type: 'ExportDefaultDeclaration',
8881
+ declaration,
8882
+ ...config,
8883
+ };
8762
8884
  }
8763
8885
  function program(body, config) {
8764
- return Object.assign({ type: 'Program', sourceType: 'module', body }, config);
8886
+ return {
8887
+ type: 'Program',
8888
+ sourceType: 'module',
8889
+ body,
8890
+ ...config,
8891
+ };
8765
8892
  }
8766
8893
  function comment$1(content) {
8767
8894
  return {
@@ -8876,7 +9003,7 @@ function elementSourceLocation(parse5ElmLocation) {
8876
9003
  const endTag = parse5ElmLocation.endTag
8877
9004
  ? sourceLocation(parse5ElmLocation.endTag)
8878
9005
  : parse5ElmLocation.endTag;
8879
- return Object.assign(Object.assign({}, elementLocation), { startTag, endTag: endTag });
9006
+ return { ...elementLocation, startTag, endTag: endTag };
8880
9007
  }
8881
9008
  function sourceLocation(location) {
8882
9009
  return {
@@ -9912,7 +10039,25 @@ const SUPPORTED_SVG_TAGS = new Set([
9912
10039
  'use',
9913
10040
  ]);
9914
10041
  const DISALLOWED_MATHML_TAGS = new Set(['script', 'link', 'base', 'object']);
9915
- const ATTRS_PROPS_TRANFORMS = Object.assign({ accesskey: 'accessKey', readonly: 'readOnly', tabindex: 'tabIndex', bgcolor: 'bgColor', colspan: 'colSpan', rowspan: 'rowSpan', contenteditable: 'contentEditable', crossorigin: 'crossOrigin', datetime: 'dateTime', formaction: 'formAction', ismap: 'isMap', maxlength: 'maxLength', minlength: 'minLength', novalidate: 'noValidate', usemap: 'useMap', for: 'htmlFor' }, shared.AriaAttrNameToPropNameMap);
10042
+ const ATTRS_PROPS_TRANFORMS = {
10043
+ accesskey: 'accessKey',
10044
+ readonly: 'readOnly',
10045
+ tabindex: 'tabIndex',
10046
+ bgcolor: 'bgColor',
10047
+ colspan: 'colSpan',
10048
+ rowspan: 'rowSpan',
10049
+ contenteditable: 'contentEditable',
10050
+ crossorigin: 'crossOrigin',
10051
+ datetime: 'dateTime',
10052
+ formaction: 'formAction',
10053
+ ismap: 'isMap',
10054
+ maxlength: 'maxLength',
10055
+ minlength: 'minLength',
10056
+ novalidate: 'noValidate',
10057
+ usemap: 'useMap',
10058
+ for: 'htmlFor',
10059
+ ...shared.AriaAttrNameToPropNameMap,
10060
+ };
9916
10061
  const DISALLOWED_HTML_TAGS = new Set(['base', 'link', 'meta', 'script', 'title']);
9917
10062
  const HTML_ATTRIBUTES_REVERSE_LOOKUP = HTML_ATTRIBUTE_ELEMENT_MAP;
9918
10063
  const KNOWN_HTML_AND_SVG_ELEMENTS = new Set([...HTML_ELEMENTS, ...SVG_ELEMENTS]);
@@ -10004,11 +10149,10 @@ class ParserCtx {
10004
10149
  return this.source.slice(start, end);
10005
10150
  }
10006
10151
  setRootDirective(root) {
10007
- var _a, _b, _c;
10008
10152
  this.renderMode =
10009
- (_b = (_a = root.directives.find(isRenderModeDirective)) === null || _a === void 0 ? void 0 : _a.value.value) !== null && _b !== void 0 ? _b : this.renderMode;
10153
+ root.directives.find(isRenderModeDirective)?.value.value ?? this.renderMode;
10010
10154
  this.preserveComments =
10011
- ((_c = root.directives.find(isPreserveCommentsDirective)) === null || _c === void 0 ? void 0 : _c.value.value) || this.preserveComments;
10155
+ root.directives.find(isPreserveCommentsDirective)?.value.value || this.preserveComments;
10012
10156
  }
10013
10157
  /**
10014
10158
  * This method flattens the scopes into a single array for traversal.
@@ -10131,8 +10275,7 @@ class ParserCtx {
10131
10275
  }
10132
10276
  }
10133
10277
  getSiblingIfNode() {
10134
- var _a;
10135
- return (_a = this.currentIfContext()) === null || _a === void 0 ? void 0 : _a.currentNode;
10278
+ return this.currentIfContext()?.currentNode;
10136
10279
  }
10137
10280
  isParsingSiblingIfBlock() {
10138
10281
  return !!this.currentIfContext();
@@ -10141,12 +10284,10 @@ class ParserCtx {
10141
10284
  return this.siblingScopes[this.siblingScopes.length - 1];
10142
10285
  }
10143
10286
  currentIfContext() {
10144
- var _a;
10145
- return (_a = this.currentSiblingContext()) === null || _a === void 0 ? void 0 : _a.ifContext;
10287
+ return this.currentSiblingContext()?.ifContext;
10146
10288
  }
10147
10289
  ancestorIfContext() {
10148
- var _a;
10149
- return (_a = this.currentSiblingContext()) === null || _a === void 0 ? void 0 : _a.ancestorIfContext;
10290
+ return this.currentSiblingContext()?.ancestorIfContext;
10150
10291
  }
10151
10292
  seenSlotsFromAncestorIfTree() {
10152
10293
  const ancestorIfContext = this.ancestorIfContext();
@@ -10245,40 +10386,6 @@ class ParserCtx {
10245
10386
  }
10246
10387
  }
10247
10388
 
10248
- /******************************************************************************
10249
- Copyright (c) Microsoft Corporation.
10250
-
10251
- Permission to use, copy, modify, and/or distribute this software for any
10252
- purpose with or without fee is hereby granted.
10253
-
10254
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10255
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10256
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10257
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10258
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
10259
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
10260
- PERFORMANCE OF THIS SOFTWARE.
10261
- ***************************************************************************** */
10262
- /* global Reflect, Promise, SuppressedError, Symbol */
10263
-
10264
-
10265
- function __rest(s, e) {
10266
- var t = {};
10267
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
10268
- t[p] = s[p];
10269
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
10270
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
10271
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
10272
- t[p[i]] = s[p[i]];
10273
- }
10274
- return t;
10275
- }
10276
-
10277
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
10278
- var e = new Error(message);
10279
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
10280
- };
10281
-
10282
10389
  /*
10283
10390
  * Copyright (c) 2018, salesforce.com, inc.
10284
10391
  * All rights reserved.
@@ -10432,8 +10539,7 @@ function validateLiteral(node) {
10432
10539
  errors.invariant(node.regex === undefined, errors.ParserDiagnostics.INVALID_EXPR_PROHIBITED_NODE_TYPE, ['regular expression literals']);
10433
10540
  }
10434
10541
  function validateNode(node, _parent, isWithinArrowFn) {
10435
- var _a, _b;
10436
- errors.invariant(!((_a = node.leadingComments) === null || _a === void 0 ? void 0 : _a.length) && !((_b = node.trailingComments) === null || _b === void 0 ? void 0 : _b.length), errors.ParserDiagnostics.INVALID_EXPR_COMMENTS_DISALLOWED);
10542
+ errors.invariant(!node.leadingComments?.length && !node.trailingComments?.length, errors.ParserDiagnostics.INVALID_EXPR_COMMENTS_DISALLOWED);
10437
10543
  errors.invariant(!STATEMENT_TYPES.has(node.type), errors.ParserDiagnostics.INVALID_EXPR_STATEMENTS_PROHIBITED);
10438
10544
  errors.invariant(!(MUTATION_TYPES.has(node.type) && !isWithinArrowFn), errors.ParserDiagnostics.INVALID_EXPR_MUTATION_OUTSIDE_ARROW);
10439
10545
  errors.invariant(!ALWAYS_INVALID_TYPES.has(node.type), errors.ParserDiagnostics.INVALID_EXPR_PROHIBITED_NODE_TYPE, [ALWAYS_INVALID_TYPES.get(node.type)]);
@@ -10617,10 +10723,10 @@ class TemplateHtmlTokenizer extends Tokenizer {
10617
10723
  }
10618
10724
  }
10619
10725
  function isTemplateExpressionTextNodeValue(value) {
10620
- return (value === null || value === void 0 ? void 0 : value[0]) === '{';
10726
+ return value?.[0] === '{';
10621
10727
  }
10622
10728
  function isTextNode(node) {
10623
- return (node === null || node === void 0 ? void 0 : node.nodeName) === '#text';
10729
+ return node?.nodeName === '#text';
10624
10730
  }
10625
10731
  function isTemplateExpressionTextNode(node) {
10626
10732
  return isTextNode(node) && isTemplateExpressionTextNodeValue(node.value);
@@ -10632,7 +10738,7 @@ function isTemplateExpressionTextNode(node) {
10632
10738
  */
10633
10739
  class TemplateHtmlParser extends Parser {
10634
10740
  constructor(extendedOpts, document, fragmentCxt) {
10635
- const { preparsedJsExpressions } = extendedOpts, options = __rest(extendedOpts, ["preparsedJsExpressions"]);
10741
+ const { preparsedJsExpressions, ...options } = extendedOpts;
10636
10742
  super(options, document, fragmentCxt);
10637
10743
  this.preparsedJsExpressions = preparsedJsExpressions;
10638
10744
  this.tokenizer = new TemplateHtmlTokenizer(this.options, this, this);
@@ -10656,7 +10762,7 @@ class TemplateHtmlParser extends Parser {
10656
10762
  const textNode = {
10657
10763
  nodeName: '#text',
10658
10764
  value: token.chars,
10659
- sourceCodeLocation: token.location ? Object.assign({}, token.location) : null,
10765
+ sourceCodeLocation: token.location ? { ...token.location } : null,
10660
10766
  parentNode,
10661
10767
  };
10662
10768
  parentNode.childNodes.push(textNode);
@@ -10683,6 +10789,12 @@ function parseFragment(source, config) {
10683
10789
  return parser.getFragment();
10684
10790
  }
10685
10791
 
10792
+ /*
10793
+ * Copyright (c) 2018, salesforce.com, inc.
10794
+ * All rights reserved.
10795
+ * SPDX-License-Identifier: MIT
10796
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
10797
+ */
10686
10798
  function getLwcErrorFromParse5Error(ctx, code) {
10687
10799
  /* istanbul ignore else */
10688
10800
  if (errorCodesToErrorOn.has(code)) {
@@ -10708,7 +10820,7 @@ function getLwcErrorFromParse5Error(ctx, code) {
10708
10820
  }
10709
10821
  function parseHTML(ctx, source) {
10710
10822
  const onParseError = (err) => {
10711
- const { code } = err, location = __rest(err, ["code"]);
10823
+ const { code, ...location } = err;
10712
10824
  const lwcError = getLwcErrorFromParse5Error(ctx, code);
10713
10825
  ctx.warnAtLocation(lwcError, sourceLocation(location), [code]);
10714
10826
  };
@@ -10856,7 +10968,7 @@ function parseExpression(ctx, source, location) {
10856
10968
  });
10857
10969
  validateSourceIsParsedExpression(source, parsed);
10858
10970
  validateExpression(parsed, ctx.config);
10859
- return Object.assign(Object.assign({}, parsed), { location });
10971
+ return { ...parsed, location };
10860
10972
  }, errors.ParserDiagnostics.TEMPLATE_EXPRESSION_PARSING_ERROR, location, (err) => `Invalid expression ${source} - ${err.message}`);
10861
10973
  }
10862
10974
  function parseIdentifier(ctx, source, location) {
@@ -10866,7 +10978,10 @@ function parseIdentifier(ctx, source, location) {
10866
10978
  isValid = acorn.isIdentifierChar(source.charCodeAt(i));
10867
10979
  }
10868
10980
  if (isValid && !isReservedES6Keyword(source)) {
10869
- return Object.assign(Object.assign({}, identifier(source)), { location });
10981
+ return {
10982
+ ...identifier(source),
10983
+ location,
10984
+ };
10870
10985
  }
10871
10986
  else {
10872
10987
  ctx.throwAtLocation(errors.ParserDiagnostics.INVALID_IDENTIFIER, location, [source]);
@@ -11175,7 +11290,7 @@ function parseElement(ctx, parse5Elm, parentNode, parse5ParentLocation) {
11175
11290
  // Create an AST node for each LWC template directive and chain them into a parent child hierarchy
11176
11291
  const directive = parseElementDirectives(ctx, parse5Elm, parse5ElmLocation, parentNode, parsedAttr);
11177
11292
  // Create an AST node for the HTML element (excluding template tag elements) and add as child to parent
11178
- const element = parseBaseElement(ctx, parsedAttr, parse5Elm, directive !== null && directive !== void 0 ? directive : parentNode, parse5ElmLocation);
11293
+ const element = parseBaseElement(ctx, parsedAttr, parse5Elm, directive ?? parentNode, parse5ElmLocation);
11179
11294
  if (element) {
11180
11295
  applyHandlers(ctx, parsedAttr, element);
11181
11296
  applyKey(ctx, parsedAttr, element);
@@ -11189,7 +11304,7 @@ function parseElement(ctx, parse5Elm, parentNode, parse5ParentLocation) {
11189
11304
  // parseBaseElement will always return an element EXCEPT when processing a <template>
11190
11305
  validateTemplate(ctx, parsedAttr, parse5Elm, parse5ElmLocation);
11191
11306
  }
11192
- const currentNode = element !== null && element !== void 0 ? element : directive;
11307
+ const currentNode = element ?? directive;
11193
11308
  if (currentNode) {
11194
11309
  parseChildren(ctx, parse5Elm, currentNode, parse5ElmLocation);
11195
11310
  validateChildren(ctx, element, directive);
@@ -11201,7 +11316,6 @@ function parseElement(ctx, parse5Elm, parentNode, parse5ParentLocation) {
11201
11316
  }
11202
11317
  }
11203
11318
  function parseElementLocation(ctx, parse5Elm, parse5ParentLocation) {
11204
- var _a;
11205
11319
  let location = parse5Elm.sourceCodeLocation;
11206
11320
  // AST hierarchy is ForBlock > If > BaseElement, if immediate parent is not a BaseElement it is a template.
11207
11321
  const parentNode = ctx.findAncestor(isBaseElement, () => false);
@@ -11210,7 +11324,7 @@ function parseElementLocation(ctx, parse5Elm, parse5ParentLocation) {
11210
11324
  // https://github.com/inikulin/parse5/blob/master/packages/parse5/docs/options/parser-options.md#sourcecodelocationinfo
11211
11325
  ctx.warn(errors.ParserDiagnostics.INVALID_HTML_RECOVERY, [
11212
11326
  parse5Elm.tagName,
11213
- (_a = parentNode === null || parentNode === void 0 ? void 0 : parentNode.name) !== null && _a !== void 0 ? _a : 'template',
11327
+ parentNode?.name ?? 'template',
11214
11328
  ]);
11215
11329
  }
11216
11330
  // With parse5 automatically recovering from invalid HTML, some AST nodes might not have
@@ -11222,7 +11336,7 @@ function parseElementLocation(ctx, parse5Elm, parse5ParentLocation) {
11222
11336
  current = current.parentNode;
11223
11337
  location = current.sourceCodeLocation;
11224
11338
  }
11225
- return location !== null && location !== void 0 ? location : parse5ParentLocation;
11339
+ return location ?? parse5ParentLocation;
11226
11340
  }
11227
11341
  const DIRECTIVE_PARSERS = [
11228
11342
  parseIfBlock,
@@ -11307,12 +11421,11 @@ function parseLwcElementAsBuiltIn(ctx, parse5Elm, _parsedAttr, parse5ElmLocation
11307
11421
  return element(tag, namespaceURI, parse5ElmLocation);
11308
11422
  }
11309
11423
  function parseChildren(ctx, parse5Parent, parent, parse5ParentLocation) {
11310
- var _a;
11311
11424
  let container = parse5Parent;
11312
11425
  // `content` isn't nullable but we need to keep the optional chaining
11313
11426
  // until parse5/tools also asserts that `content` is set. It should be
11314
11427
  // 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) {
11428
+ if (isTemplateNode(parse5Parent) && parse5Parent.content?.childNodes.length > 0) {
11316
11429
  container = parse5Parent.content;
11317
11430
  }
11318
11431
  const children = container.childNodes;
@@ -11377,7 +11490,10 @@ function parseText(ctx, parse5Text) {
11377
11490
  if (!preparsedExpression) {
11378
11491
  throw new Error('Implementation error: cannot find preparsed template expression');
11379
11492
  }
11380
- const value = Object.assign(Object.assign({}, preparsedExpression), { location: sourceLocation(location) });
11493
+ const value = {
11494
+ ...preparsedExpression,
11495
+ location: sourceLocation(location),
11496
+ };
11381
11497
  return [text(rawText, value, location)];
11382
11498
  }
11383
11499
  // Split the text node content arround expression and create node for each
@@ -11410,13 +11526,12 @@ function parseComment(parse5Comment) {
11410
11526
  return comment(parse5Comment.data, decodeTextContent(parse5Comment.data), location);
11411
11527
  }
11412
11528
  function getTemplateRoot(ctx, documentFragment) {
11413
- var _a;
11414
11529
  // Filter all the empty text nodes
11415
11530
  const validRoots = documentFragment.childNodes.filter((child) => isElementNode(child) ||
11416
11531
  (isTextNode$1(child) && child.value.trim().length));
11417
11532
  if (validRoots.length > 1) {
11418
- const duplicateRoot = (_a = validRoots[1].sourceCodeLocation) !== null && _a !== void 0 ? _a : undefined;
11419
- ctx.throw(errors.ParserDiagnostics.MULTIPLE_ROOTS_FOUND, [], duplicateRoot ? sourceLocation(duplicateRoot) : duplicateRoot !== null && duplicateRoot !== void 0 ? duplicateRoot : undefined);
11533
+ const duplicateRoot = validRoots[1].sourceCodeLocation ?? undefined;
11534
+ ctx.throw(errors.ParserDiagnostics.MULTIPLE_ROOTS_FOUND, [], duplicateRoot ? sourceLocation(duplicateRoot) : duplicateRoot ?? undefined);
11420
11535
  }
11421
11536
  const [root] = validRoots;
11422
11537
  if (!root || !isElementNode(root)) {
@@ -11548,7 +11663,6 @@ function applyRootLwcDirectives(ctx, parsedAttr, root) {
11548
11663
  applyLwcPreserveCommentsDirective(ctx, parsedAttr, root);
11549
11664
  }
11550
11665
  function applyLwcRenderModeDirective(ctx, parsedAttr, root) {
11551
- var _a;
11552
11666
  const lwcRenderModeAttribute = parsedAttr.pick(exports.RootDirectiveName.RenderMode);
11553
11667
  if (!lwcRenderModeAttribute) {
11554
11668
  return;
@@ -11560,7 +11674,7 @@ function applyLwcRenderModeDirective(ctx, parsedAttr, root) {
11560
11674
  ctx.throwOnNode(errors.ParserDiagnostics.LWC_RENDER_MODE_INVALID_VALUE, root);
11561
11675
  }
11562
11676
  root.directives.push(renderModeDirective(renderDomAttr.value, lwcRenderModeAttribute.location));
11563
- (_a = ctx.instrumentation) === null || _a === void 0 ? void 0 : _a.incrementCounter(errors.CompilerMetrics.LWCRenderModeDirective);
11677
+ ctx.instrumentation?.incrementCounter(errors.CompilerMetrics.LWCRenderModeDirective);
11564
11678
  }
11565
11679
  function applyLwcPreserveCommentsDirective(ctx, parsedAttr, root) {
11566
11680
  const lwcPreserveCommentAttribute = parsedAttr.pick(exports.RootDirectiveName.PreserveComments);
@@ -11660,7 +11774,6 @@ function applyLwcExternalDirective(ctx, parsedAttr, element) {
11660
11774
  }
11661
11775
  }
11662
11776
  function applyLwcDynamicDirective(ctx, parsedAttr, element) {
11663
- var _a;
11664
11777
  const { name: tag } = element;
11665
11778
  const lwcDynamicAttribute = parsedAttr.pick(exports.ElementDirectiveName.Dynamic);
11666
11779
  if (!lwcDynamicAttribute) {
@@ -11680,7 +11793,7 @@ function applyLwcDynamicDirective(ctx, parsedAttr, element) {
11680
11793
  }
11681
11794
  // lwc:dynamic will be deprecated in 246, issue a warning when usage is detected.
11682
11795
  ctx.warnOnNode(errors.ParserDiagnostics.DEPRECATED_LWC_DYNAMIC_ATTRIBUTE, element);
11683
- (_a = ctx.instrumentation) === null || _a === void 0 ? void 0 : _a.incrementCounter(errors.CompilerMetrics.LWCDynamicDirective);
11796
+ ctx.instrumentation?.incrementCounter(errors.CompilerMetrics.LWCDynamicDirective);
11684
11797
  element.directives.push(dynamicDirective(lwcDynamicAttr, location));
11685
11798
  }
11686
11799
  function applyLwcIsDirective(ctx, parsedAttr, element) {
@@ -11847,7 +11960,7 @@ function parseScopedSlotFragment(ctx, parse5Elm, parse5ElmLocation, parent, pars
11847
11960
  slotName = slotAttr.value;
11848
11961
  }
11849
11962
  const identifier = parseIdentifier(ctx, slotDataAttrValue.value, slotDataAttr.location);
11850
- const node = scopedSlotFragment(identifier, sourceLocation(parse5ElmLocation), slotDataAttr.location, slotName !== null && slotName !== void 0 ? slotName : literal(''));
11963
+ const node = scopedSlotFragment(identifier, sourceLocation(parse5ElmLocation), slotDataAttr.location, slotName ?? literal(''));
11851
11964
  ctx.addNodeCurrentElementScope(node);
11852
11965
  parent.children.push(node);
11853
11966
  return node;
@@ -12189,7 +12302,7 @@ function parseAttributes(ctx, parse5Elm, parse5ElmLocation) {
12189
12302
  const { attrs: attributes, tagName } = parse5Elm;
12190
12303
  const { attrs: attrLocations } = parse5ElmLocation;
12191
12304
  for (const attr of attributes) {
12192
- const attrLocation = attrLocations === null || attrLocations === void 0 ? void 0 : attrLocations[attributeName(attr).toLowerCase()];
12305
+ const attrLocation = attrLocations?.[attributeName(attr).toLowerCase()];
12193
12306
  /* istanbul ignore if */
12194
12307
  if (!attrLocation) {
12195
12308
  throw new Error('An internal parsing error occurred while parsing attributes; attributes were found without a location.');
@@ -12435,9 +12548,9 @@ function isStaticNode(node, apiVersion) {
12435
12548
  return false;
12436
12549
  }
12437
12550
  // it is an element
12438
- result && (result = isElement(node));
12551
+ result &&= isElement(node);
12439
12552
  // all attrs are static-safe
12440
- result && (result = attributes.every(({ name, value }) => {
12553
+ result &&= attributes.every(({ name, value }) => {
12441
12554
  return (isLiteral(value) &&
12442
12555
  name !== 'slot' &&
12443
12556
  // check for ScopedId
@@ -12449,11 +12562,11 @@ function isStaticNode(node, apiVersion) {
12449
12562
  // Check for ScopedFragId
12450
12563
  !(isAllowedFragOnlyUrlsXHTML(nodeName, name, namespace) &&
12451
12564
  isFragmentOnlyUrl(value.value)));
12452
- }));
12565
+ });
12453
12566
  // all directives are static-safe
12454
- result && (result = !directives.some((directive) => !STATIC_SAFE_DIRECTIVES.has(directive.name)));
12567
+ result &&= !directives.some((directive) => !STATIC_SAFE_DIRECTIVES.has(directive.name));
12455
12568
  // all properties are static
12456
- result && (result = properties.every((prop) => isLiteral(prop.value)));
12569
+ result &&= properties.every((prop) => isLiteral(prop.value));
12457
12570
  return result;
12458
12571
  }
12459
12572
  function collectStaticNodes(node, staticNodes, state) {
@@ -12469,7 +12582,7 @@ function collectStaticNodes(node, staticNodes, state) {
12469
12582
  // it is ElseBlock | ForBlock | If | BaseElement
12470
12583
  node.children.forEach((childNode) => {
12471
12584
  collectStaticNodes(childNode, staticNodes, state);
12472
- childrenAreStatic && (childrenAreStatic = staticNodes.has(childNode));
12585
+ childrenAreStatic &&= staticNodes.has(childNode);
12473
12586
  });
12474
12587
  // for IfBlock and ElseifBlock, traverse down the else branch
12475
12588
  if (isConditionalParentBlock(node) && node.else) {
@@ -12672,13 +12785,12 @@ class ExpressionScopes {
12672
12785
  this.arrowFnVariables = new Map();
12673
12786
  }
12674
12787
  enterScope(node) {
12675
- var _a;
12676
12788
  const variableNamesIntroduced = new Set();
12677
12789
  for (const param of node.params) {
12678
12790
  collectParams(param, variableNamesIntroduced);
12679
12791
  }
12680
12792
  for (const varName of variableNamesIntroduced) {
12681
- this.variableShadowingCount.set(varName, ((_a = this.variableShadowingCount.get(varName)) !== null && _a !== void 0 ? _a : 0) + 1);
12793
+ this.variableShadowingCount.set(varName, (this.variableShadowingCount.get(varName) ?? 0) + 1);
12682
12794
  }
12683
12795
  this.arrowFnVariables.set(node, variableNamesIntroduced);
12684
12796
  }
@@ -12789,7 +12901,6 @@ const RENDER_APIS = {
12789
12901
  };
12790
12902
  class CodeGen {
12791
12903
  constructor({ root, state, scopeFragmentId, }) {
12792
- var _a, _b, _c, _d;
12793
12904
  this.staticNodes = new Set();
12794
12905
  this.hoistedNodes = [];
12795
12906
  /** True if this template contains the lwc:ref directive */
@@ -12807,9 +12918,11 @@ class CodeGen {
12807
12918
  this.staticNodes = getStaticNodes(root, state);
12808
12919
  }
12809
12920
  this.renderMode =
12810
- (_b = (_a = root.directives.find(isRenderModeDirective)) === null || _a === void 0 ? void 0 : _a.value.value) !== null && _b !== void 0 ? _b : exports.LWCDirectiveRenderMode.shadow;
12921
+ root.directives.find(isRenderModeDirective)?.value.value ??
12922
+ exports.LWCDirectiveRenderMode.shadow;
12811
12923
  this.preserveComments =
12812
- (_d = (_c = root.directives.find(isPreserveCommentsDirective)) === null || _c === void 0 ? void 0 : _c.value.value) !== null && _d !== void 0 ? _d : state.config.preserveHtmlComments;
12924
+ root.directives.find(isPreserveCommentsDirective)?.value.value ??
12925
+ state.config.preserveHtmlComments;
12813
12926
  this.scopeFragmentId = scopeFragmentId;
12814
12927
  this.scope = this.createScope();
12815
12928
  this.state = state;
@@ -13021,6 +13134,8 @@ class CodeGen {
13021
13134
  if (this.state.config.experimentalComplexExpressions) {
13022
13135
  return bindComplexExpression(expression, this);
13023
13136
  }
13137
+ // We need access to both this `this` and the walker's `this` in the walker
13138
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
13024
13139
  const scope = this;
13025
13140
  // Cloning here is necessary because `this.replace()` is destructive, and we might use the
13026
13141
  // node later during static content optimization
@@ -13453,7 +13568,7 @@ function transform(codeGen) {
13453
13568
  * @returns A conditional expression representing the full conditional tree with conditionalParentBlock as the root node
13454
13569
  */
13455
13570
  function transformConditionalParentBlock(conditionalParentBlock, key) {
13456
- const ifBlockKey = key !== null && key !== void 0 ? key : codeGen.generateKey();
13571
+ const ifBlockKey = key ?? codeGen.generateKey();
13457
13572
  const childrenExpression = codeGen.genFragment(literal$1(ifBlockKey), transformChildren(conditionalParentBlock));
13458
13573
  let elseExpression = literal$1(null);
13459
13574
  if (conditionalParentBlock.else) {
@@ -13485,7 +13600,7 @@ function transform(codeGen) {
13485
13600
  messageArgs: [modifier],
13486
13601
  });
13487
13602
  }
13488
- return conditionalExpression(leftExpression, node, falseValue !== null && falseValue !== void 0 ? falseValue : literal$1(null));
13603
+ return conditionalExpression(leftExpression, node, falseValue ?? literal$1(null));
13489
13604
  }
13490
13605
  function transformForBlock(forBlock) {
13491
13606
  let expression = transformForChildren(forBlock);
@@ -13721,7 +13836,7 @@ function transform(codeGen) {
13721
13836
  if (spread) {
13722
13837
  // spread goes last, so it can be used to override any other properties
13723
13838
  propsObj.properties.push(spreadElement(codeGen.bindExpression(spread.value)));
13724
- instrumentation === null || instrumentation === void 0 ? void 0 : instrumentation.incrementCounter(errors.CompilerMetrics.LWCSpreadDirective);
13839
+ instrumentation?.incrementCounter(errors.CompilerMetrics.LWCSpreadDirective);
13725
13840
  }
13726
13841
  if (propsObj.properties.length) {
13727
13842
  data.push(property$1(identifier('props'), propsObj));
@@ -13855,5 +13970,5 @@ function compile(source, config) {
13855
13970
  exports.compile = compile;
13856
13971
  exports.default = compile;
13857
13972
  exports.parse = parse;
13858
- /** version: 6.1.1 */
13973
+ /** version: 6.2.0 */
13859
13974
  //# sourceMappingURL=index.cjs.js.map