]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: beforeXXX hooks
authorEvan You <yyx990803@gmail.com>
Wed, 29 May 2019 02:47:09 +0000 (10:47 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 29 May 2019 02:47:09 +0000 (10:47 +0800)
packages/runtime-core/src/createRenderer.ts

index 0b1d0cc1d6cd5c0d0289c1419890ed3172367e0e..b5afeb1cdd501166c885982c957984726e8fac78 100644 (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)
       }