@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.
@@ -5805,17 +5805,30 @@ function recursivelyDisconnectChildren(vnodes) {
5805
5805
  // into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
5806
5806
  // children VNodes might not be representing the current state of the DOM.
5807
5807
  function resetComponentRoot(vm) {
5808
- const { children, renderRoot, renderer: { remove }, } = vm;
5809
- for (let i = 0, len = children.length; i < len; i++) {
5810
- const child = children[i];
5811
- if (!isNull(child) && !isUndefined$1(child.elm)) {
5812
- remove(child.elm, renderRoot);
5813
- }
5814
- }
5808
+ recursivelyRemoveChildren(vm.children, vm);
5815
5809
  vm.children = EmptyArray;
5816
5810
  runChildNodesDisconnectedCallback(vm);
5817
5811
  vm.velements = EmptyArray;
5818
5812
  }
5813
+ // Helper function to remove all children of the root node.
5814
+ // If the set of children includes VFragment nodes, we need to remove the children of those nodes too.
5815
+ // Since VFragments can contain other VFragments, we need to traverse the entire of tree of VFragments.
5816
+ // If the set contains no VFragment nodes, no traversal is needed.
5817
+ function recursivelyRemoveChildren(vnodes, vm) {
5818
+ const { renderRoot, renderer: { remove }, } = vm;
5819
+ for (let i = 0, len = vnodes.length; i < len; i += 1) {
5820
+ const vnode = vnodes[i];
5821
+ if (!isNull(vnode)) {
5822
+ // VFragments are special; their .elm property does not point to the root element since they have no single root.
5823
+ if (isVFragment(vnode)) {
5824
+ recursivelyRemoveChildren(vnode.children, vm);
5825
+ }
5826
+ else if (!isUndefined$1(vnode.elm)) {
5827
+ remove(vnode.elm, renderRoot);
5828
+ }
5829
+ }
5830
+ }
5831
+ }
5819
5832
  function scheduleRehydration(vm) {
5820
5833
  if (!process.env.IS_BROWSER || isTrue(vm.isScheduled)) {
5821
5834
  return;
@@ -6856,5 +6869,5 @@ function readonly(obj) {
6856
6869
  }
6857
6870
 
6858
6871
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6859
- /* version: 2.38.0 */
6872
+ /* version: 2.38.1 */
6860
6873
  //# sourceMappingURL=engine-core.js.map