extract getRealChild for abstract components

This commit is contained in:
Evan You 2016-07-06 17:07:46 -04:00
parent d4a167e7c6
commit 9421bd4806
5 changed files with 16 additions and 17 deletions

View File

@ -44,10 +44,7 @@ declare interface VNodeData {
staticAttrs?: { [key: string]: string };
hook?: { [key: string]: Function };
on?: { [key: string]: Function | Array<Function> };
transition?: {
definition: String | Object,
appear: boolean
};
transition?: string | Object;
inlineTemplate?: {
render: Function,
staticRenderFns: Array<Function>

View File

@ -1,4 +1,5 @@
import { callHook } from 'core/instance/lifecycle'
import { getRealChild } from 'core/vdom/helpers'
export default {
name: 'keep-alive',
@ -30,14 +31,3 @@ export default {
}
}
}
// in case the child is also an abstract component, e.g. <transition-control>
// we want to recrusively retrieve the real component to be rendered
function getRealChild (vnode) {
const compOptions = vnode && vnode.componentOptions
if (compOptions && compOptions.Ctor.options._abstract) {
return getRealChild(compOptions.propsData.child)
} else {
return vnode
}
}

View File

@ -86,7 +86,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
vm.$el.__vue__ = vm
}
// update parent vnode element after patch
const parentNode = vm.$options._parentVnode
const parentNode = vm.$vnode
if (parentNode) {
parentNode.elm = vm.$el
// update parent $el if the parent is HOC

View File

@ -62,6 +62,17 @@ function applyNS (vnode, ns) {
}
}
// in case the child is also an abstract component, e.g. <transition-control>
// we want to recrusively retrieve the real component to be rendered
export function getRealChild (vnode) {
const compOptions = vnode && vnode.componentOptions
if (compOptions && compOptions.Ctor.options._abstract) {
return getRealChild(compOptions.propsData.child)
} else {
return vnode
}
}
export function updateListeners (
on: Object,
oldOn: Object,

View File

@ -1,6 +1,7 @@
/* flow */
import { warn } from 'core/util/index'
import { getRealChild } from 'core/vdom/helpers'
export default {
name: 'transition-control',
@ -20,7 +21,7 @@ export default {
},
render () {
const oldChild = this._vnode
const newChild = this.child
const newChild = getRealChild(this.child)
if (oldChild && oldChild.data && (
oldChild.tag !== newChild.tag ||
oldChild.key !== newChild.key