wip: beforeXXX hooks

This commit is contained in:
Evan You 2019-05-29 10:47:09 +08:00
parent eac8a4baa3
commit 3f281d5ea6

View File

@ -365,6 +365,7 @@ export function createRenderer(options: RendererOptions) {
instance,
needsSetup
))
// beforeMount hook
if (instance.bm !== null) {
invokeHooks(instance.bm)
}
@ -384,6 +385,10 @@ export function createRenderer(options: RendererOptions) {
}
const prevTree = instance.subTree
const nextTree = (instance.subTree = renderComponentRoot(instance))
// beforeUpdate hook
if (instance.bu !== null) {
invokeHooks(instance.bu)
}
patch(
prevTree,
nextTree,
@ -678,9 +683,14 @@ export function createRenderer(options: RendererOptions) {
function unmount(vnode: VNode, doRemove?: boolean) {
const instance = vnode.component
if (instance != null) {
// beforeUnmount hook
if (instance.bum !== null) {
invokeHooks(instance.bum)
}
// TODO teardown component
stop(instance.update)
unmount(instance.subTree, doRemove)
// unmounted hook
if (instance.um !== null) {
queuePostFlushCb(instance.um)
}