Skip to content

Commit 30258a9

Browse files
committed
rename vnode.child -> vnode.componentInstance
1 parent 9b384bd commit 30258a9

File tree

9 files changed

+36
-36
lines changed

9 files changed

+36
-36
lines changed

Diff for: flow/vnode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ declare type VNodeComponentOptions = {
1010

1111
declare type MountedComponentVNode = {
1212
componentOptions: VNodeComponentOptions;
13-
child: Component;
13+
componentInstance: Component;
1414
parent: VNode;
1515
data: VNodeData;
1616
}
@@ -26,7 +26,7 @@ declare type VNodeWithData = {
2626
context: Component;
2727
key: string | number | void;
2828
parent?: VNodeWithData;
29-
child?: Component;
29+
componentInstance?: Component;
3030
isRootInsert: boolean;
3131
}
3232

Diff for: src/core/components/keep-alive.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default {
4141
? opts.Ctor.cid + (opts.tag ? `::${opts.tag}` : '')
4242
: vnode.key
4343
if (this.cache[key]) {
44-
vnode.child = this.cache[key].child
44+
vnode.componentInstance = this.cache[key].componentInstance
4545
} else {
4646
this.cache[key] = vnode
4747
}
@@ -52,8 +52,8 @@ export default {
5252
destroyed () {
5353
for (const key in this.cache) {
5454
const vnode = this.cache[key]
55-
callHook(vnode.child, 'deactivated')
56-
vnode.child.$destroy()
55+
callHook(vnode.componentInstance, 'deactivated')
56+
vnode.componentInstance.$destroy()
5757
}
5858
}
5959
}

Diff for: src/core/vdom/create-component.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ function init (
157157
parentElm: ?Node,
158158
refElm: ?Node
159159
): ?boolean {
160-
if (!vnode.child || vnode.child._isDestroyed) {
161-
const child = vnode.child = createComponentInstanceForVnode(
160+
if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
161+
const child = vnode.componentInstance = createComponentInstanceForVnode(
162162
vnode,
163163
activeInstance,
164164
parentElm,
@@ -177,7 +177,7 @@ function prepatch (
177177
vnode: MountedComponentVNode
178178
) {
179179
const options = vnode.componentOptions
180-
const child = vnode.child = oldVnode.child
180+
const child = vnode.componentInstance = oldVnode.componentInstance
181181
child._updateFromParent(
182182
options.propsData, // updated props
183183
options.listeners, // updated listeners
@@ -187,23 +187,23 @@ function prepatch (
187187
}
188188

189189
function insert (vnode: MountedComponentVNode) {
190-
if (!vnode.child._isMounted) {
191-
vnode.child._isMounted = true
192-
callHook(vnode.child, 'mounted')
190+
if (!vnode.componentInstance._isMounted) {
191+
vnode.componentInstance._isMounted = true
192+
callHook(vnode.componentInstance, 'mounted')
193193
}
194194
if (vnode.data.keepAlive) {
195-
vnode.child._inactive = false
196-
callHook(vnode.child, 'activated')
195+
vnode.componentInstance._inactive = false
196+
callHook(vnode.componentInstance, 'activated')
197197
}
198198
}
199199

200200
function destroy (vnode: MountedComponentVNode) {
201-
if (!vnode.child._isDestroyed) {
201+
if (!vnode.componentInstance._isDestroyed) {
202202
if (!vnode.data.keepAlive) {
203-
vnode.child.$destroy()
203+
vnode.componentInstance.$destroy()
204204
} else {
205-
vnode.child._inactive = true
206-
callHook(vnode.child, 'deactivated')
205+
vnode.componentInstance._inactive = true
206+
callHook(vnode.componentInstance, 'deactivated')
207207
}
208208
}
209209
}

Diff for: src/core/vdom/modules/ref.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function registerRef (vnode: VNodeWithData, isRemoval: ?boolean) {
2222
if (!key) return
2323

2424
const vm = vnode.context
25-
const ref = vnode.child || vnode.elm
25+
const ref = vnode.componentInstance || vnode.elm
2626
const refs = vm.$refs
2727
if (isRemoval) {
2828
if (Array.isArray(refs[key])) {

Diff for: src/core/vdom/patch.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ export function createPatchFunction (backend) {
160160
function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
161161
let i = vnode.data
162162
if (isDef(i)) {
163-
const isReactivated = isDef(vnode.child) && i.keepAlive
163+
const isReactivated = isDef(vnode.componentInstance) && i.keepAlive
164164
if (isDef(i = i.hook) && isDef(i = i.init)) {
165165
i(vnode, false /* hydrating */, parentElm, refElm)
166166
}
167167
// after calling the init hook, if the vnode is a child component
168168
// it should've created a child instance and mounted it. the child
169169
// component also has set the placeholder vnode's elm.
170170
// in that case we can just return the element and be done.
171-
if (isDef(vnode.child)) {
171+
if (isDef(vnode.componentInstance)) {
172172
initComponent(vnode, insertedVnodeQueue)
173173
if (isReactivated) {
174174
reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm)
@@ -185,8 +185,8 @@ export function createPatchFunction (backend) {
185185
// again. It's not ideal to involve module-specific logic in here but
186186
// there doesn't seem to be a better way to do it.
187187
let innerNode = vnode
188-
while (innerNode.child) {
189-
innerNode = innerNode.child._vnode
188+
while (innerNode.componentInstance) {
189+
innerNode = innerNode.componentInstance._vnode
190190
if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
191191
for (i = 0; i < cbs.activate.length; ++i) {
192192
cbs.activate[i](emptyNode, innerNode)
@@ -221,8 +221,8 @@ export function createPatchFunction (backend) {
221221
}
222222

223223
function isPatchable (vnode) {
224-
while (vnode.child) {
225-
vnode = vnode.child._vnode
224+
while (vnode.componentInstance) {
225+
vnode = vnode.componentInstance._vnode
226226
}
227227
return isDef(vnode.tag)
228228
}
@@ -242,7 +242,7 @@ export function createPatchFunction (backend) {
242242
if (vnode.data.pendingInsert) {
243243
insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert)
244244
}
245-
vnode.elm = vnode.child.$el
245+
vnode.elm = vnode.componentInstance.$el
246246
if (isPatchable(vnode)) {
247247
invokeCreateHooks(vnode, insertedVnodeQueue)
248248
setScope(vnode)
@@ -316,7 +316,7 @@ export function createPatchFunction (backend) {
316316
rm.listeners += listeners
317317
}
318318
// recursively invoke hooks on child component root node
319-
if (isDef(i = vnode.child) && isDef(i = i._vnode) && isDef(i.data)) {
319+
if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
320320
removeAndInvokeRemoveHook(i, rm)
321321
}
322322
for (i = 0; i < cbs.remove.length; ++i) {
@@ -420,7 +420,7 @@ export function createPatchFunction (backend) {
420420
vnode.key === oldVnode.key &&
421421
(vnode.isCloned || vnode.isOnce)) {
422422
vnode.elm = oldVnode.elm
423-
vnode.child = oldVnode.child
423+
vnode.componentInstance = oldVnode.componentInstance
424424
return
425425
}
426426
let i
@@ -483,7 +483,7 @@ export function createPatchFunction (backend) {
483483
const { tag, data, children } = vnode
484484
if (isDef(data)) {
485485
if (isDef(i = data.hook) && isDef(i = i.init)) i(vnode, true /* hydrating */)
486-
if (isDef(i = vnode.child)) {
486+
if (isDef(i = vnode.componentInstance)) {
487487
// child component. it should have hydrated its own tree.
488488
initComponent(vnode, insertedVnodeQueue)
489489
return true

Diff for: src/core/vdom/vnode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class VNode {
1111
functionalContext: Component | void; // only for functional component root nodes
1212
key: string | number | void;
1313
componentOptions: VNodeComponentOptions | void;
14-
child: Component | void; // component instance
14+
componentInstance: Component | void; // component instance
1515
parent: VNode | void; // component placeholder node
1616
raw: boolean; // contains raw HTML? (server only)
1717
isStatic: boolean; // hoisted static node
@@ -39,7 +39,7 @@ export default class VNode {
3939
this.functionalContext = undefined
4040
this.key = data && data.key
4141
this.componentOptions = componentOptions
42-
this.child = undefined
42+
this.componentInstance = undefined
4343
this.parent = undefined
4444
this.raw = false
4545
this.isStatic = false

Diff for: src/platforms/web/runtime/directives/show.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { enter, leave } from '../modules/transition'
55

66
// recursively search for possible transition defined inside the component root
77
function locateNode (vnode: VNode): VNodeWithData {
8-
return vnode.child && (!vnode.data || !vnode.data.transition)
9-
? locateNode(vnode.child._vnode)
8+
return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
9+
? locateNode(vnode.componentInstance._vnode)
1010
: vnode
1111
}
1212

Diff for: src/platforms/web/util/class.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export function genClassForVnode (vnode: VNode): string {
66
let data = vnode.data
77
let parentNode = vnode
88
let childNode = vnode
9-
while (childNode.child) {
10-
childNode = childNode.child._vnode
9+
while (childNode.componentInstance) {
10+
childNode = childNode.componentInstance._vnode
1111
if (childNode.data) {
1212
data = mergeClassData(childNode.data, data)
1313
}

Diff for: src/platforms/web/util/style.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export function getStyle (vnode: VNode, checkChild: boolean): Object {
4646

4747
if (checkChild) {
4848
let childNode = vnode
49-
while (childNode.child) {
50-
childNode = childNode.child._vnode
49+
while (childNode.componentInstance) {
50+
childNode = childNode.componentInstance._vnode
5151
if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
5252
extend(res, styleData)
5353
}

0 commit comments

Comments
 (0)