@lwc/template-compiler 7.0.0 → 7.0.1-alpha.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.
@@ -69,7 +69,7 @@ export default class CodeGen {
69
69
  genScopedId(id: string | t.Expression): t.CallExpression;
70
70
  genScopedFragId(id: string | t.Expression): t.CallExpression;
71
71
  genClassExpression(value: Expression): import("estree").Expression;
72
- genNormalizeClassName(className: t.Expression): t.CallExpression;
72
+ genNormalizeClassName(className: t.Expression): t.CallExpression | t.ConditionalExpression;
73
73
  /**
74
74
  * Generates childs vnodes when slot content is static.
75
75
  * @param slotName
package/dist/index.cjs.js CHANGED
@@ -11072,6 +11072,9 @@ class TemplateHtmlTokenizer extends Tokenizer {
11072
11072
  function isTemplateExpressionTextNodeValue(value) {
11073
11073
  return value?.[0] === '{';
11074
11074
  }
11075
+ function isTemplateElement(node) {
11076
+ return node.nodeName === 'template';
11077
+ }
11075
11078
  function isTextNode(node) {
11076
11079
  return node?.nodeName === '#text';
11077
11080
  }
@@ -11112,7 +11115,12 @@ class TemplateHtmlParser extends Parser {
11112
11115
  sourceCodeLocation: token.location ? { ...token.location } : null,
11113
11116
  parentNode,
11114
11117
  };
11115
- parentNode.childNodes.push(textNode);
11118
+ if (isTemplateElement(parentNode)) {
11119
+ parentNode.content.childNodes.push(textNode);
11120
+ }
11121
+ else {
11122
+ parentNode.childNodes.push(textNode);
11123
+ }
11116
11124
  }
11117
11125
  }
11118
11126
  /**
@@ -13600,7 +13608,7 @@ class CodeGen {
13600
13608
  return classExpression;
13601
13609
  }
13602
13610
  genNormalizeClassName(className) {
13603
- return this._renderApiCall(RENDER_APIS.normalizeClassName, [className]);
13611
+ return this._renderApiCall(RENDER_APIS.normalizeClassName, [className], className);
13604
13612
  }
13605
13613
  /**
13606
13614
  * Generates childs vnodes when slot content is static.
@@ -13698,13 +13706,18 @@ class CodeGen {
13698
13706
  // usage of the lwc:inner-html, and in an iteration, usages are dynamically generated.
13699
13707
  return conditionalExpression(binaryExpression('!==', memberExpression(identifier(TEMPLATE_PARAMS.CONTEXT), identifier(`_rawHtml$${instance}`)), assignmentExpression('=', memberExpression(identifier(TEMPLATE_PARAMS.CONTEXT), identifier(`_rawHtml$${instance}`)), expr)), assignmentExpression('=', memberExpression(identifier(TEMPLATE_PARAMS.CONTEXT), identifier(`_sanitizedHtml$${instance}`)), this.genSanitizeHtmlContent(expr)), memberExpression(identifier(TEMPLATE_PARAMS.CONTEXT), identifier(`_sanitizedHtml$${instance}`)));
13700
13708
  }
13701
- _renderApiCall(primitive, params) {
13709
+ _renderApiCall(primitive, params, fallbackForCompilerEngineVersionMismatch) {
13702
13710
  const { name, alias } = primitive;
13703
13711
  let identifier$1 = this.usedApis[name];
13704
13712
  if (!identifier$1) {
13705
13713
  identifier$1 = this.usedApis[name] = identifier(alias);
13706
13714
  }
13707
- return callExpression(identifier$1, params);
13715
+ const callExpression$1 = callExpression(identifier$1, params);
13716
+ // Check if the property actually exists before calling, to allow
13717
+ // for older engines to work with newer compilers
13718
+ return fallbackForCompilerEngineVersionMismatch
13719
+ ? conditionalExpression(identifier$1, callExpression$1, fallbackForCompilerEngineVersionMismatch)
13720
+ : callExpression$1;
13708
13721
  }
13709
13722
  beginScope() {
13710
13723
  this.scope = this.createScope(this.scope);