@lwc/template-compiler 6.2.1 → 6.3.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/index.cjs.js CHANGED
@@ -10706,7 +10706,7 @@ class TemplateHtmlTokenizer extends Tokenizer {
10706
10706
  // coming later in an unquoted attr value should not be considered
10707
10707
  // the beginning of a template expression.
10708
10708
  this.checkedAttrs.add(this.currentAttr);
10709
- // @ts-ignore
10709
+ // @ts-expect-error private method
10710
10710
  super._stateAttributeValueUnquoted(codePoint);
10711
10711
  }
10712
10712
  }
@@ -10739,7 +10739,7 @@ class TemplateHtmlTokenizer extends Tokenizer {
10739
10739
  this.currentCharacterToken = null;
10740
10740
  }
10741
10741
  else {
10742
- // @ts-ignore
10742
+ // @ts-expect-error private method
10743
10743
  super._stateData(codePoint);
10744
10744
  }
10745
10745
  }
@@ -11503,7 +11503,23 @@ function parseText(ctx, parse5Text) {
11503
11503
  }
11504
11504
  // Extract the raw source to avoid HTML entity decoding done by parse5
11505
11505
  const rawText = cleanTextNode(ctx.getSource(location.startOffset, location.endOffset));
11506
- if (!rawText.trim().length) {
11506
+ /*
11507
+ The original job of this if-block was to discard the whitespace between HTML tags, HTML
11508
+ comments, and HTML tags and HTML comments. The whitespace inside the text content of HTML tags
11509
+ would never be considered here because they would not be parsed into individual text nodes until
11510
+ later (several lines below).
11511
+
11512
+ ["Hello {first} {last}!"] => ["Hello ", "{first}", " ", "{last}", "!"]
11513
+
11514
+ With the implementation of complex template expressions, whitespace that shouldn't be discarded
11515
+ has already been parsed into individual text nodes at this point so we only discard when
11516
+ experimentalComplexExpressions is disabled.
11517
+
11518
+ When removing the experimentalComplexExpressions flag, we need to figure out how to best discard
11519
+ the HTML whitespace while preserving text content whitespace, while also taking into account how
11520
+ comments are sometimes preserved (in which case we need to keep the HTML whitespace).
11521
+ */
11522
+ if (!rawText.trim().length && !ctx.config.experimentalComplexExpressions) {
11507
11523
  return parsedTextNodes;
11508
11524
  }
11509
11525
  // TODO [#3370]: remove experimental template expression flag
@@ -13169,6 +13185,9 @@ class CodeGen {
13169
13185
  }
13170
13186
  // TODO [#3370]: remove experimental template expression flag
13171
13187
  if (this.state.config.experimentalComplexExpressions) {
13188
+ // Cloning here is necessary because `this.replace()` is destructive, and we might use the
13189
+ // node later during static content optimization
13190
+ expression = doStructuredClone(expression);
13172
13191
  return bindComplexExpression(expression, this);
13173
13192
  }
13174
13193
  // We need access to both this `this` and the walker's `this` in the walker
@@ -14020,5 +14039,5 @@ function compile(source, config) {
14020
14039
  exports.compile = compile;
14021
14040
  exports.default = compile;
14022
14041
  exports.parse = parse;
14023
- /** version: 6.2.1 */
14042
+ /** version: 6.3.1 */
14024
14043
  //# sourceMappingURL=index.cjs.js.map