Skip to content

Commit

Permalink
fix(runtime): clean deferredConnectedCallbacks array on disconnectedC…
Browse files Browse the repository at this point in the history
…allback (#6142)
  • Loading branch information
christian-bromann authored Feb 4, 2025
1 parent 0691295 commit 788dfd0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/runtime/bootstrap-lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,16 @@ export const bootstrapLazy = (lazyBundles: d.LazyBundlesRuntimeData, options: d.
* node that was removed. This is necessary to ensure that these
* references used as keys in the `hostRef` object can be properly
* garbage collected.
*
* Also remove the reference from `deferredConnectedCallbacks` array
* otherwise removed instances won't get garbage collected.
*/
plt.raf(() => {
const hostRef = getHostRef(this);
const i = deferredConnectedCallbacks.findIndex((host) => host === this);
if (i > -1) {
deferredConnectedCallbacks.splice(i, 1);
}
if (hostRef?.$vnode$?.$elm$ instanceof Node && !hostRef.$vnode$.$elm$.isConnected) {
delete hostRef.$vnode$.$elm$;
}
Expand Down

0 comments on commit 788dfd0

Please sign in to comment.