@lwc/engine-core 6.6.6 → 6.7.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
@@ -3453,12 +3453,25 @@ function swapTemplate(oldTpl, newTpl) {
3453
3453
  }
3454
3454
  function swapComponent(oldComponent, newComponent) {
3455
3455
  if (process.env.NODE_ENV !== 'production') {
3456
- if (isComponentConstructor(oldComponent) && isComponentConstructor(newComponent)) {
3456
+ const isOldCtorAComponent = isComponentConstructor(oldComponent);
3457
+ const isNewCtorAComponent = isComponentConstructor(newComponent);
3458
+ if (isOldCtorAComponent && isNewCtorAComponent) {
3457
3459
  swappedComponentMap.set(oldComponent, newComponent);
3458
3460
  return rehydrateHotComponent(oldComponent);
3459
3461
  }
3462
+ else if (isOldCtorAComponent === false && isNewCtorAComponent === true) {
3463
+ throw new TypeError(`Invalid Component: Attempting to swap a non-component with a component`);
3464
+ }
3465
+ else if (isOldCtorAComponent === true && isNewCtorAComponent === false) {
3466
+ throw new TypeError(`Invalid Component: Attempting to swap a component with a non-component`);
3467
+ }
3460
3468
  else {
3461
- throw new TypeError(`Invalid Component`);
3469
+ // The dev-server relies on the presence of registerComponent() as a way to determine a
3470
+ // component module. However, the compiler cannot definitively add registerComponent()
3471
+ // transformation only to a component constructor. Hence the dev-server may attempt to
3472
+ // hot swap javascript modules that look like a component and should not cause the app
3473
+ // to fail. To allow that, this api ignores such hot swap attempts.
3474
+ return false;
3462
3475
  }
3463
3476
  }
3464
3477
  return false;
@@ -7636,6 +7649,7 @@ function haveCompatibleStaticParts(vnode, renderer) {
7636
7649
  if (shared.isUndefined(parts)) {
7637
7650
  return true;
7638
7651
  }
7652
+ const shouldValidateAttr = (data, attrName) => attrName in data;
7639
7653
  // The validation here relies on 2 key invariants:
7640
7654
  // 1. It's never the case that `parts` is undefined on the server but defined on the client (or vice-versa)
7641
7655
  // 2. It's never the case that `parts` has one length on the server but another on the client
@@ -7647,8 +7661,15 @@ function haveCompatibleStaticParts(vnode, renderer) {
7647
7661
  }
7648
7662
  const { data } = part;
7649
7663
  const hasMatchingAttrs = validateAttrs(vnode, elm, data, renderer, () => true);
7650
- const hasMatchingStyleAttr = validateStyleAttr(vnode, elm, data, renderer);
7651
- const hasMatchingClass = validateClassAttr(vnode, elm, data, renderer);
7664
+ // Explicitly skip hydration validation when static parts don't contain `style` or `className`.
7665
+ // This means the style/class attributes are either static or don't exist on the element and
7666
+ // cannot be affected by hydration.
7667
+ const hasMatchingStyleAttr = shouldValidateAttr(data, 'style')
7668
+ ? validateStyleAttr(vnode, elm, data, renderer)
7669
+ : true;
7670
+ const hasMatchingClass = shouldValidateAttr(data, 'className')
7671
+ ? validateClassAttr(vnode, elm, data, renderer)
7672
+ : true;
7652
7673
  if (shared.isFalse(hasMatchingAttrs && hasMatchingStyleAttr && hasMatchingClass)) {
7653
7674
  return false;
7654
7675
  }
@@ -7977,5 +7998,5 @@ exports.swapTemplate = swapTemplate;
7977
7998
  exports.track = track;
7978
7999
  exports.unwrap = unwrap;
7979
8000
  exports.wire = wire;
7980
- /** version: 6.6.6 */
8001
+ /** version: 6.7.0 */
7981
8002
  //# sourceMappingURL=index.cjs.js.map