From 30258a9a60b96c25c95685cb17ee35838830ee4c Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 12 Jan 2017 17:44:03 -0500 Subject: [PATCH] rename vnode.child -> vnode.componentInstance --- flow/vnode.js | 4 ++-- src/core/components/keep-alive.js | 6 ++--- src/core/vdom/create-component.js | 24 ++++++++++---------- src/core/vdom/modules/ref.js | 2 +- src/core/vdom/patch.js | 20 ++++++++-------- src/core/vdom/vnode.js | 4 ++-- src/platforms/web/runtime/directives/show.js | 4 ++-- src/platforms/web/util/class.js | 4 ++-- src/platforms/web/util/style.js | 4 ++-- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/flow/vnode.js b/flow/vnode.js index 805bdae79b2..84adf2f3347 100644 --- a/flow/vnode.js +++ b/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; } diff --git a/src/core/components/keep-alive.js b/src/core/components/keep-alive.js index 8810ded227c..4c9b190d647 100644 --- a/src/core/components/keep-alive.js +++ b/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() } } } diff --git a/src/core/vdom/create-component.js b/src/core/vdom/create-component.js index 8833cd5c4e8..0d6b96a0740 100644 --- a/src/core/vdom/create-component.js +++ b/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') } } } diff --git a/src/core/vdom/modules/ref.js b/src/core/vdom/modules/ref.js index 040e8ead532..c69547ce7a3 100644 --- a/src/core/vdom/modules/ref.js +++ b/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])) { diff --git a/src/core/vdom/patch.js b/src/core/vdom/patch.js index 347567de367..74743bed19e 100644 --- a/src/core/vdom/patch.js +++ b/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 diff --git a/src/core/vdom/vnode.js b/src/core/vdom/vnode.js index 49d8e4b6662..1f3d4e845fb 100644 --- a/src/core/vdom/vnode.js +++ b/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 diff --git a/src/platforms/web/runtime/directives/show.js b/src/platforms/web/runtime/directives/show.js index d429af3c78d..8e51adc1efe 100644 --- a/src/platforms/web/runtime/directives/show.js +++ b/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 } diff --git a/src/platforms/web/util/class.js b/src/platforms/web/util/class.js index cb9a311ac8d..c75c457b925 100644 --- a/src/platforms/web/util/class.js +++ b/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) } diff --git a/src/platforms/web/util/style.js b/src/platforms/web/util/style.js index 7d45034ac5e..7b0663736e5 100644 --- a/src/platforms/web/util/style.js +++ b/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) }