Skip to content

Commit 9421bd4

Browse files
committed
extract getRealChild for abstract components
1 parent d4a167e commit 9421bd4

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

flow/vnode.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ declare interface VNodeData {
4444
staticAttrs?: { [key: string]: string };
4545
hook?: { [key: string]: Function };
4646
on?: { [key: string]: Function | Array<Function> };
47-
transition?: {
48-
definition: String | Object,
49-
appear: boolean
50-
};
47+
transition?: string | Object;
5148
inlineTemplate?: {
5249
render: Function,
5350
staticRenderFns: Array<Function>

src/core/components/keep-alive.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { callHook } from 'core/instance/lifecycle'
2+
import { getRealChild } from 'core/vdom/helpers'
23

34
export default {
45
name: 'keep-alive',
@@ -30,14 +31,3 @@ export default {
3031
}
3132
}
3233
}
33-
34-
// in case the child is also an abstract component, e.g. <transition-control>
35-
// we want to recrusively retrieve the real component to be rendered
36-
function getRealChild (vnode) {
37-
const compOptions = vnode && vnode.componentOptions
38-
if (compOptions && compOptions.Ctor.options._abstract) {
39-
return getRealChild(compOptions.propsData.child)
40-
} else {
41-
return vnode
42-
}
43-
}

src/core/instance/lifecycle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
8686
vm.$el.__vue__ = vm
8787
}
8888
// update parent vnode element after patch
89-
const parentNode = vm.$options._parentVnode
89+
const parentNode = vm.$vnode
9090
if (parentNode) {
9191
parentNode.elm = vm.$el
9292
// update parent $el if the parent is HOC

src/core/vdom/helpers.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ function applyNS (vnode, ns) {
6262
}
6363
}
6464

65+
// in case the child is also an abstract component, e.g. <transition-control>
66+
// we want to recrusively retrieve the real component to be rendered
67+
export function getRealChild (vnode) {
68+
const compOptions = vnode && vnode.componentOptions
69+
if (compOptions && compOptions.Ctor.options._abstract) {
70+
return getRealChild(compOptions.propsData.child)
71+
} else {
72+
return vnode
73+
}
74+
}
75+
6576
export function updateListeners (
6677
on: Object,
6778
oldOn: Object,

src/platforms/web/runtime/components/transition-control.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* flow */
22

33
import { warn } from 'core/util/index'
4+
import { getRealChild } from 'core/vdom/helpers'
45

56
export default {
67
name: 'transition-control',
@@ -20,7 +21,7 @@ export default {
2021
},
2122
render () {
2223
const oldChild = this._vnode
23-
const newChild = this.child
24+
const newChild = getRealChild(this.child)
2425
if (oldChild && oldChild.data && (
2526
oldChild.tag !== newChild.tag ||
2627
oldChild.key !== newChild.key

0 commit comments

Comments
 (0)