]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: rename vnode hooks
authorEvan You <yyx990803@gmail.com>
Fri, 18 Oct 2019 18:01:45 +0000 (14:01 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 18 Oct 2019 18:54:35 +0000 (14:54 -0400)
So that they can be used as @vnodeMounted="..." in templates

packages/runtime-core/src/createRenderer.ts
packages/runtime-core/src/directives.ts
packages/shared/src/index.ts
packages/shared/src/patchFlags.ts

index 0a059c00175e691bd3fe8afd29f733a53d797c0f..9d2fc51ecdc16ac003fedb286b4b5963e98e9a19 100644 (file)
@@ -346,8 +346,8 @@ export function createRenderer<
         if (isReservedProp(key)) continue
         hostPatchProp(el, key, props[key], null, isSVG)
       }
-      if (props.vnodeBeforeMount != null) {
-        invokeDirectiveHook(props.vnodeBeforeMount, parentComponent, vnode)
+      if (props.onVnodeBeforeMount != null) {
+        invokeDirectiveHook(props.onVnodeBeforeMount, parentComponent, vnode)
       }
     }
     if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
@@ -363,9 +363,9 @@ export function createRenderer<
       )
     }
     hostInsert(el, container, anchor)
-    if (props != null && props.vnodeMounted != null) {
+    if (props != null && props.onVnodeMounted != null) {
       queuePostRenderEffect(() => {
-        invokeDirectiveHook(props.vnodeMounted, parentComponent, vnode)
+        invokeDirectiveHook(props.onVnodeMounted, parentComponent, vnode)
       }, parentSuspense)
     }
   }
@@ -406,8 +406,8 @@ export function createRenderer<
     const oldProps = (n1 && n1.props) || EMPTY_OBJ
     const newProps = n2.props || EMPTY_OBJ
 
-    if (newProps.vnodeBeforeUpdate != null) {
-      invokeDirectiveHook(newProps.vnodeBeforeUpdate, parentComponent, n2, n1)
+    if (newProps.onVnodeBeforeUpdate != null) {
+      invokeDirectiveHook(newProps.onVnodeBeforeUpdate, parentComponent, n2, n1)
     }
 
     if (patchFlag > 0) {
@@ -508,9 +508,9 @@ export function createRenderer<
       patchChildren(n1, n2, el, null, parentComponent, parentSuspense, isSVG)
     }
 
-    if (newProps.vnodeUpdated != null) {
+    if (newProps.onVnodeUpdated != null) {
       queuePostRenderEffect(() => {
-        invokeDirectiveHook(newProps.vnodeUpdated, parentComponent, n2, n1)
+        invokeDirectiveHook(newProps.onVnodeUpdated, parentComponent, n2, n1)
       }, parentSuspense)
     }
   }
@@ -1682,8 +1682,8 @@ export function createRenderer<
       return
     }
 
-    if (props != null && props.vnodeBeforeUnmount != null) {
-      invokeDirectiveHook(props.vnodeBeforeUnmount, parentComponent, vnode)
+    if (props != null && props.onVnodeBeforeUnmount != null) {
+      invokeDirectiveHook(props.onVnodeBeforeUnmount, parentComponent, vnode)
     }
 
     const shouldRemoveChildren = type === Fragment && doRemove
@@ -1708,9 +1708,9 @@ export function createRenderer<
       if (anchor != null) hostRemove(anchor)
     }
 
-    if (props != null && props.vnodeUnmounted != null) {
+    if (props != null && props.onVnodeUnmounted != null) {
       queuePostRenderEffect(() => {
-        invokeDirectiveHook(props.vnodeUnmounted, parentComponent, vnode)
+        invokeDirectiveHook(props.onVnodeUnmounted, parentComponent, vnode)
       }, parentSuspense)
     }
   }
index 01c9a83246c25f3a4a78fa08328a1e2d370fe15c..088695040d6ebb50b1ebb7ccf08f16b325a3a540 100644 (file)
@@ -84,7 +84,7 @@ function applyDirective(
 
   for (const key in directive) {
     const hook = directive[key as keyof ObjectDirective]!
-    const hookKey = `vnode` + key[0].toUpperCase() + key.slice(1)
+    const hookKey = `onVnode` + key[0].toUpperCase() + key.slice(1)
     const vnodeHook = (vnode: VNode, prevVNode: VNode | null) => {
       let oldValue
       if (prevVNode != null) {
index 4511f4f637f5f88e602edbfd1978d1e2d591cd7a..a866a99bf67bb282b9565a6cd2c8316abb858af9 100644 (file)
@@ -52,9 +52,8 @@ export const toTypeString = (value: unknown): string =>
 export const isPlainObject = (val: any): val is object =>
   toTypeString(val) === '[object Object]'
 
-const vnodeHooksRE = /^vnode/
 export const isReservedProp = (key: string): boolean =>
-  key === 'key' || key === 'ref' || key === '$once' || vnodeHooksRE.test(key)
+  key === 'key' || key === 'ref' || key === '$once' || key.startsWith(`onVnode`)
 
 const camelizeRE = /-(\w)/g
 export const camelize = (str: string): string => {
index 3bdee641a72939ad5d0da2860558d0891604f88a..48fe939b0d18c7d96151369b59c9812382cb604e 100644 (file)
@@ -41,8 +41,8 @@ export const enum PatchFlags {
   FULL_PROPS = 1 << 4,
 
   // Indicates an element that only needs non-props patching, e.g. ref or
-  // directives (vnodeXXX hooks). It simply marks the vnode as "need patch",
-  // since every patched vnode checks for refs and vnodeXXX hooks.
+  // directives (onVnodeXXX hooks). It simply marks the vnode as "need patch",
+  // since every patched vnode checks for refs and onVnodeXXX hooks.
   // This flag is never directly matched against, it simply serves as a non-zero
   // value.
   NEED_PATCH = 1 << 5,