mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-02 12:07:39 +08:00
extract getRealChild for abstract components
This commit is contained in:
parent
d4a167e7c6
commit
9421bd4806
@ -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>
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user