@lwc/engine-core 2.38.0 → 2.38.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.
@@ -5807,17 +5807,30 @@ function recursivelyDisconnectChildren(vnodes) {
5807
5807
  // into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
5808
5808
  // children VNodes might not be representing the current state of the DOM.
5809
5809
  function resetComponentRoot(vm) {
5810
- const { children, renderRoot, renderer: { remove }, } = vm;
5811
- for (let i = 0, len = children.length; i < len; i++) {
5812
- const child = children[i];
5813
- if (!shared.isNull(child) && !shared.isUndefined(child.elm)) {
5814
- remove(child.elm, renderRoot);
5815
- }
5816
- }
5810
+ recursivelyRemoveChildren(vm.children, vm);
5817
5811
  vm.children = EmptyArray;
5818
5812
  runChildNodesDisconnectedCallback(vm);
5819
5813
  vm.velements = EmptyArray;
5820
5814
  }
5815
+ // Helper function to remove all children of the root node.
5816
+ // If the set of children includes VFragment nodes, we need to remove the children of those nodes too.
5817
+ // Since VFragments can contain other VFragments, we need to traverse the entire of tree of VFragments.
5818
+ // If the set contains no VFragment nodes, no traversal is needed.
5819
+ function recursivelyRemoveChildren(vnodes, vm) {
5820
+ const { renderRoot, renderer: { remove }, } = vm;
5821
+ for (let i = 0, len = vnodes.length; i < len; i += 1) {
5822
+ const vnode = vnodes[i];
5823
+ if (!shared.isNull(vnode)) {
5824
+ // VFragments are special; their .elm property does not point to the root element since they have no single root.
5825
+ if (isVFragment(vnode)) {
5826
+ recursivelyRemoveChildren(vnode.children, vm);
5827
+ }
5828
+ else if (!shared.isUndefined(vnode.elm)) {
5829
+ remove(vnode.elm, renderRoot);
5830
+ }
5831
+ }
5832
+ }
5833
+ }
5821
5834
  function scheduleRehydration(vm) {
5822
5835
  if (!process.env.IS_BROWSER || shared.isTrue(vm.isScheduled)) {
5823
5836
  return;
@@ -6895,5 +6908,5 @@ exports.swapTemplate = swapTemplate;
6895
6908
  exports.track = track;
6896
6909
  exports.unwrap = unwrap;
6897
6910
  exports.wire = wire;
6898
- /* version: 2.38.0 */
6911
+ /* version: 2.38.1 */
6899
6912
  //# sourceMappingURL=engine-core.cjs.js.map