(
instance: ComponentInternalInstance,
parentSuspense: SuspenseBoundary | null,
doRemove?: boolean,
)
| 2331 | } |
| 2332 | |
| 2333 | const unmountComponent = ( |
| 2334 | instance: ComponentInternalInstance, |
| 2335 | parentSuspense: SuspenseBoundary | null, |
| 2336 | doRemove?: boolean, |
| 2337 | ) => { |
| 2338 | if (__DEV__ && instance.type.__hmrId) { |
| 2339 | unregisterHMR(instance) |
| 2340 | } |
| 2341 | |
| 2342 | const { bum, scope, job, subTree, um, m, a } = instance |
| 2343 | invalidateMount(m) |
| 2344 | invalidateMount(a) |
| 2345 | |
| 2346 | // beforeUnmount hook |
| 2347 | if (bum) { |
| 2348 | invokeArrayFns(bum) |
| 2349 | } |
| 2350 | |
| 2351 | if ( |
| 2352 | __COMPAT__ && |
| 2353 | isCompatEnabled(DeprecationTypes.INSTANCE_EVENT_HOOKS, instance) |
| 2354 | ) { |
| 2355 | instance.emit('hook:beforeDestroy') |
| 2356 | } |
| 2357 | |
| 2358 | // stop effects in component scope |
| 2359 | scope.stop() |
| 2360 | |
| 2361 | // job may be null if a component is unmounted before its async |
| 2362 | // setup has resolved. |
| 2363 | if (job) { |
| 2364 | // so that scheduler will no longer invoke it |
| 2365 | job.flags! |= SchedulerJobFlags.DISPOSED |
| 2366 | unmount(subTree, instance, parentSuspense, doRemove) |
| 2367 | } |
| 2368 | // unmounted hook |
| 2369 | if (um) { |
| 2370 | queuePostRenderEffect(um, parentSuspense) |
| 2371 | } |
| 2372 | if ( |
| 2373 | __COMPAT__ && |
| 2374 | isCompatEnabled(DeprecationTypes.INSTANCE_EVENT_HOOKS, instance) |
| 2375 | ) { |
| 2376 | queuePostRenderEffect( |
| 2377 | () => instance.emit('hook:destroyed'), |
| 2378 | parentSuspense, |
| 2379 | ) |
| 2380 | } |
| 2381 | queuePostRenderEffect(() => { |
| 2382 | instance.isUnmounted = true |
| 2383 | }, parentSuspense) |
| 2384 | |
| 2385 | if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { |
| 2386 | devtoolsComponentRemoved(instance) |
| 2387 | } |
| 2388 | } |
| 2389 | |
| 2390 | const unmountChildren: UnmountChildrenFn = ( |
no test coverage detected