Quellcode durchsuchen

rename vnode.child -> vnode.componentInstance

Evan You vor 9 Jahren
Ursprung
Commit
30258a9a60

+ 2 - 2
flow/vnode.js

@@ -10,7 +10,7 @@ declare type VNodeComponentOptions = {
 
 declare type MountedComponentVNode = {
   componentOptions: VNodeComponentOptions;
-  child: Component;
+  componentInstance: Component;
   parent: VNode;
   data: VNodeData;
 }
@@ -26,7 +26,7 @@ declare type VNodeWithData = {
   context: Component;
   key: string | number | void;
   parent?: VNodeWithData;
-  child?: Component;
+  componentInstance?: Component;
   isRootInsert: boolean;
 }
 

+ 3 - 3
src/core/components/keep-alive.js

@@ -41,7 +41,7 @@ export default {
         ? opts.Ctor.cid + (opts.tag ? `::${opts.tag}` : '')
         : vnode.key
       if (this.cache[key]) {
-        vnode.child = this.cache[key].child
+        vnode.componentInstance = this.cache[key].componentInstance
       } else {
         this.cache[key] = vnode
       }
@@ -52,8 +52,8 @@ export default {
   destroyed () {
     for (const key in this.cache) {
       const vnode = this.cache[key]
-      callHook(vnode.child, 'deactivated')
-      vnode.child.$destroy()
+      callHook(vnode.componentInstance, 'deactivated')
+      vnode.componentInstance.$destroy()
     }
   }
 }

+ 12 - 12
src/core/vdom/create-component.js

@@ -157,8 +157,8 @@ function init (
   parentElm: ?Node,
   refElm: ?Node
 ): ?boolean {
-  if (!vnode.child || vnode.child._isDestroyed) {
-    const child = vnode.child = createComponentInstanceForVnode(
+  if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
+    const child = vnode.componentInstance = createComponentInstanceForVnode(
       vnode,
       activeInstance,
       parentElm,
@@ -177,7 +177,7 @@ function prepatch (
   vnode: MountedComponentVNode
 ) {
   const options = vnode.componentOptions
-  const child = vnode.child = oldVnode.child
+  const child = vnode.componentInstance = oldVnode.componentInstance
   child._updateFromParent(
     options.propsData, // updated props
     options.listeners, // updated listeners
@@ -187,23 +187,23 @@ function prepatch (
 }
 
 function insert (vnode: MountedComponentVNode) {
-  if (!vnode.child._isMounted) {
-    vnode.child._isMounted = true
-    callHook(vnode.child, 'mounted')
+  if (!vnode.componentInstance._isMounted) {
+    vnode.componentInstance._isMounted = true
+    callHook(vnode.componentInstance, 'mounted')
   }
   if (vnode.data.keepAlive) {
-    vnode.child._inactive = false
-    callHook(vnode.child, 'activated')
+    vnode.componentInstance._inactive = false
+    callHook(vnode.componentInstance, 'activated')
   }
 }
 
 function destroy (vnode: MountedComponentVNode) {
-  if (!vnode.child._isDestroyed) {
+  if (!vnode.componentInstance._isDestroyed) {
     if (!vnode.data.keepAlive) {
-      vnode.child.$destroy()
+      vnode.componentInstance.$destroy()
     } else {
-      vnode.child._inactive = true
-      callHook(vnode.child, 'deactivated')
+      vnode.componentInstance._inactive = true
+      callHook(vnode.componentInstance, 'deactivated')
     }
   }
 }

+ 1 - 1
src/core/vdom/modules/ref.js

@@ -22,7 +22,7 @@ export function registerRef (vnode: VNodeWithData, isRemoval: ?boolean) {
   if (!key) return
 
   const vm = vnode.context
-  const ref = vnode.child || vnode.elm
+  const ref = vnode.componentInstance || vnode.elm
   const refs = vm.$refs
   if (isRemoval) {
     if (Array.isArray(refs[key])) {

+ 10 - 10
src/core/vdom/patch.js

@@ -160,7 +160,7 @@ export function createPatchFunction (backend) {
   function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
     let i = vnode.data
     if (isDef(i)) {
-      const isReactivated = isDef(vnode.child) && i.keepAlive
+      const isReactivated = isDef(vnode.componentInstance) && i.keepAlive
       if (isDef(i = i.hook) && isDef(i = i.init)) {
         i(vnode, false /* hydrating */, parentElm, refElm)
       }
@@ -168,7 +168,7 @@ export function createPatchFunction (backend) {
       // it should've created a child instance and mounted it. the child
       // component also has set the placeholder vnode's elm.
       // in that case we can just return the element and be done.
-      if (isDef(vnode.child)) {
+      if (isDef(vnode.componentInstance)) {
         initComponent(vnode, insertedVnodeQueue)
         if (isReactivated) {
           reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm)
@@ -185,8 +185,8 @@ export function createPatchFunction (backend) {
     // again. It's not ideal to involve module-specific logic in here but
     // there doesn't seem to be a better way to do it.
     let innerNode = vnode
-    while (innerNode.child) {
-      innerNode = innerNode.child._vnode
+    while (innerNode.componentInstance) {
+      innerNode = innerNode.componentInstance._vnode
       if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
         for (i = 0; i < cbs.activate.length; ++i) {
           cbs.activate[i](emptyNode, innerNode)
@@ -221,8 +221,8 @@ export function createPatchFunction (backend) {
   }
 
   function isPatchable (vnode) {
-    while (vnode.child) {
-      vnode = vnode.child._vnode
+    while (vnode.componentInstance) {
+      vnode = vnode.componentInstance._vnode
     }
     return isDef(vnode.tag)
   }
@@ -242,7 +242,7 @@ export function createPatchFunction (backend) {
     if (vnode.data.pendingInsert) {
       insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert)
     }
-    vnode.elm = vnode.child.$el
+    vnode.elm = vnode.componentInstance.$el
     if (isPatchable(vnode)) {
       invokeCreateHooks(vnode, insertedVnodeQueue)
       setScope(vnode)
@@ -316,7 +316,7 @@ export function createPatchFunction (backend) {
         rm.listeners += listeners
       }
       // recursively invoke hooks on child component root node
-      if (isDef(i = vnode.child) && isDef(i = i._vnode) && isDef(i.data)) {
+      if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
         removeAndInvokeRemoveHook(i, rm)
       }
       for (i = 0; i < cbs.remove.length; ++i) {
@@ -420,7 +420,7 @@ export function createPatchFunction (backend) {
         vnode.key === oldVnode.key &&
         (vnode.isCloned || vnode.isOnce)) {
       vnode.elm = oldVnode.elm
-      vnode.child = oldVnode.child
+      vnode.componentInstance = oldVnode.componentInstance
       return
     }
     let i
@@ -483,7 +483,7 @@ export function createPatchFunction (backend) {
     const { tag, data, children } = vnode
     if (isDef(data)) {
       if (isDef(i = data.hook) && isDef(i = i.init)) i(vnode, true /* hydrating */)
-      if (isDef(i = vnode.child)) {
+      if (isDef(i = vnode.componentInstance)) {
         // child component. it should have hydrated its own tree.
         initComponent(vnode, insertedVnodeQueue)
         return true

+ 2 - 2
src/core/vdom/vnode.js

@@ -11,7 +11,7 @@ export default class VNode {
   functionalContext: Component | void; // only for functional component root nodes
   key: string | number | void;
   componentOptions: VNodeComponentOptions | void;
-  child: Component | void; // component instance
+  componentInstance: Component | void; // component instance
   parent: VNode | void; // component placeholder node
   raw: boolean; // contains raw HTML? (server only)
   isStatic: boolean; // hoisted static node
@@ -39,7 +39,7 @@ export default class VNode {
     this.functionalContext = undefined
     this.key = data && data.key
     this.componentOptions = componentOptions
-    this.child = undefined
+    this.componentInstance = undefined
     this.parent = undefined
     this.raw = false
     this.isStatic = false

+ 2 - 2
src/platforms/web/runtime/directives/show.js

@@ -5,8 +5,8 @@ import { enter, leave } from '../modules/transition'
 
 // recursively search for possible transition defined inside the component root
 function locateNode (vnode: VNode): VNodeWithData {
-  return vnode.child && (!vnode.data || !vnode.data.transition)
-    ? locateNode(vnode.child._vnode)
+  return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
+    ? locateNode(vnode.componentInstance._vnode)
     : vnode
 }
 

+ 2 - 2
src/platforms/web/util/class.js

@@ -6,8 +6,8 @@ export function genClassForVnode (vnode: VNode): string {
   let data = vnode.data
   let parentNode = vnode
   let childNode = vnode
-  while (childNode.child) {
-    childNode = childNode.child._vnode
+  while (childNode.componentInstance) {
+    childNode = childNode.componentInstance._vnode
     if (childNode.data) {
       data = mergeClassData(childNode.data, data)
     }

+ 2 - 2
src/platforms/web/util/style.js

@@ -46,8 +46,8 @@ export function getStyle (vnode: VNode, checkChild: boolean): Object {
 
   if (checkChild) {
     let childNode = vnode
-    while (childNode.child) {
-      childNode = childNode.child._vnode
+    while (childNode.componentInstance) {
+      childNode = childNode.componentInstance._vnode
       if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
         extend(res, styleData)
       }