@@ -970,6 +970,7 @@ export function createRenderer<
970
970
setupRenderEffect (
971
971
instance ,
972
972
parentSuspense ,
973
+ parentComponent ,
973
974
initialVNode ,
974
975
container ,
975
976
anchor ,
@@ -984,6 +985,7 @@ export function createRenderer<
984
985
function setupRenderEffect (
985
986
instance : ComponentInternalInstance ,
986
987
parentSuspense : HostSuspenseBoundary | null ,
988
+ parentComponent : ComponentInternalInstance | null ,
987
989
initialVNode : HostVNode ,
988
990
container : HostElement ,
989
991
anchor : HostNode | null ,
@@ -993,16 +995,29 @@ export function createRenderer<
993
995
instance . update = effect ( function componentEffect ( ) {
994
996
if ( ! instance . isMounted ) {
995
997
const subTree = ( instance . subTree = renderComponentRoot ( instance ) )
998
+ const { props } = instance . vnode
996
999
// beforeMount hook
997
1000
if ( instance . bm !== null ) {
998
1001
invokeHooks ( instance . bm )
999
1002
}
1003
+ if ( props && props . onVnodeBeforeMount != null ) {
1004
+ invokeDirectiveHook (
1005
+ props . onVnodeBeforeMount ,
1006
+ parentComponent ,
1007
+ subTree
1008
+ )
1009
+ }
1000
1010
patch ( null , subTree , container , anchor , instance , parentSuspense , isSVG )
1001
1011
initialVNode . el = subTree . el
1002
1012
// mounted hook
1003
1013
if ( instance . m !== null ) {
1004
1014
queuePostRenderEffect ( instance . m , parentSuspense )
1005
1015
}
1016
+ if ( props && props . onVnodeMounted != null ) {
1017
+ queuePostRenderEffect ( ( ) => {
1018
+ invokeDirectiveHook ( props . onVnodeMounted ! , parentComponent , subTree )
1019
+ } , parentSuspense )
1020
+ }
1006
1021
// activated hook for keep-alive roots.
1007
1022
if (
1008
1023
instance . a !== null &&
@@ -1016,6 +1031,7 @@ export function createRenderer<
1016
1031
// This is triggered by mutation of component's own state (next: null)
1017
1032
// OR parent calling processComponent (next: HostVNode)
1018
1033
const { next } = instance
1034
+ const { props } = instance . vnode
1019
1035
1020
1036
if ( __DEV__ ) {
1021
1037
pushWarningContext ( next || instance . vnode )
@@ -1031,6 +1047,14 @@ export function createRenderer<
1031
1047
if ( instance . bu !== null ) {
1032
1048
invokeHooks ( instance . bu )
1033
1049
}
1050
+ if ( props && props . onVnodeBeforeUpdate != null ) {
1051
+ invokeDirectiveHook (
1052
+ props . onVnodeBeforeUpdate ,
1053
+ parentComponent ,
1054
+ nextTree ,
1055
+ prevTree
1056
+ )
1057
+ }
1034
1058
// reset refs
1035
1059
// only needed if previous patch had refs
1036
1060
if ( instance . refs !== EMPTY_OBJ ) {
@@ -1058,6 +1082,16 @@ export function createRenderer<
1058
1082
if ( instance . u !== null ) {
1059
1083
queuePostRenderEffect ( instance . u , parentSuspense )
1060
1084
}
1085
+ if ( props && props . onVnodeUpdated != null ) {
1086
+ queuePostRenderEffect ( ( ) => {
1087
+ invokeDirectiveHook (
1088
+ props . onVnodeUpdated ! ,
1089
+ parentComponent ,
1090
+ nextTree ,
1091
+ prevTree
1092
+ )
1093
+ } , parentSuspense )
1094
+ }
1061
1095
1062
1096
if ( __DEV__ ) {
1063
1097
popWarningContext ( )
@@ -1539,7 +1573,12 @@ export function createRenderer<
1539
1573
if ( shapeFlag & ShapeFlags . COMPONENT_SHOULD_KEEP_ALIVE ) {
1540
1574
; ( parentComponent ! . sink as KeepAliveSink ) . deactivate ( vnode )
1541
1575
} else {
1542
- unmountComponent ( vnode . component ! , parentSuspense , doRemove )
1576
+ unmountComponent (
1577
+ vnode . component ! ,
1578
+ parentSuspense ,
1579
+ parentComponent ,
1580
+ doRemove
1581
+ )
1543
1582
}
1544
1583
return
1545
1584
}
@@ -1621,17 +1660,31 @@ export function createRenderer<
1621
1660
function unmountComponent (
1622
1661
instance : ComponentInternalInstance ,
1623
1662
parentSuspense : HostSuspenseBoundary | null ,
1663
+ parentComponent : ComponentInternalInstance | null ,
1624
1664
doRemove ?: boolean
1625
1665
) {
1626
1666
if ( __HMR__ && instance . type . __hmrId != null ) {
1627
1667
unregisterHMR ( instance )
1628
1668
}
1629
1669
1630
- const { bum, effects, update, subTree, um, da, isDeactivated } = instance
1670
+ const {
1671
+ bum,
1672
+ effects,
1673
+ update,
1674
+ subTree,
1675
+ um,
1676
+ da,
1677
+ isDeactivated,
1678
+ vnode
1679
+ } = instance
1680
+ const { props } = vnode
1631
1681
// beforeUnmount hook
1632
1682
if ( bum !== null ) {
1633
1683
invokeHooks ( bum )
1634
1684
}
1685
+ if ( props && props . onVnodeBeforeUnmount != null ) {
1686
+ invokeDirectiveHook ( props . onVnodeBeforeUnmount , parentComponent , subTree )
1687
+ }
1635
1688
if ( effects !== null ) {
1636
1689
for ( let i = 0 ; i < effects . length ; i ++ ) {
1637
1690
stop ( effects [ i ] )
@@ -1647,6 +1700,11 @@ export function createRenderer<
1647
1700
if ( um !== null ) {
1648
1701
queuePostRenderEffect ( um , parentSuspense )
1649
1702
}
1703
+ if ( props && props . onVnodeUnmounted != null ) {
1704
+ queuePostRenderEffect ( ( ) => {
1705
+ invokeDirectiveHook ( props . onVnodeUnmounted ! , parentComponent , subTree )
1706
+ } , parentSuspense )
1707
+ }
1650
1708
// deactivated hook
1651
1709
if (
1652
1710
da !== null &&
0 commit comments