File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
packages/runtime-core/src/compat Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change 1
1
import {
2
2
isReactive ,
3
3
reactive ,
4
+ stop ,
4
5
track ,
5
6
TrackOpTypes ,
6
7
trigger ,
@@ -13,7 +14,8 @@ import {
13
14
EMPTY_OBJ ,
14
15
isArray ,
15
16
isObject ,
16
- isString
17
+ isString ,
18
+ invokeArrayFns
17
19
} from '@vue/shared'
18
20
import { warn } from '../warning'
19
21
import { cloneVNode , createVNode } from '../vnode'
@@ -467,8 +469,28 @@ export function installCompatMount(
467
469
devtoolsUnmountApp ( app )
468
470
}
469
471
delete app . _container . __vue_app__
470
- } else if ( __DEV__ ) {
471
- warn ( `Cannot unmount an app that is not mounted.` )
472
+ } else {
473
+ const { bum, effects, um } = instance
474
+ // beforeDestroy hooks
475
+ if ( bum ) {
476
+ invokeArrayFns ( bum )
477
+ }
478
+ if ( isCompatEnabled ( DeprecationTypes . INSTANCE_EVENT_HOOKS , instance ) ) {
479
+ instance . emit ( 'hook:beforeDestroy' )
480
+ }
481
+ // stop effects
482
+ if ( effects ) {
483
+ for ( let i = 0 ; i < effects . length ; i ++ ) {
484
+ stop ( effects [ i ] )
485
+ }
486
+ }
487
+ // unmounted hook
488
+ if ( um ) {
489
+ invokeArrayFns ( um )
490
+ }
491
+ if ( isCompatEnabled ( DeprecationTypes . INSTANCE_EVENT_HOOKS , instance ) ) {
492
+ instance . emit ( 'hook:destroyed' )
493
+ }
472
494
}
473
495
}
474
496
You can’t perform that action at this time.
0 commit comments