|
|
@@ -18,6 +18,7 @@ import {
|
|
|
} from '../util/index'
|
|
|
|
|
|
export let activeInstance: any = null
|
|
|
+export let isUpdatingChildComponent: boolean = false
|
|
|
|
|
|
export function initLifecycle (vm: Component) {
|
|
|
const options = vm.$options
|
|
|
@@ -207,6 +208,10 @@ export function updateChildComponent (
|
|
|
parentVnode: VNode,
|
|
|
renderChildren: ?Array<VNode>
|
|
|
) {
|
|
|
+ if (process.env.NODE_ENV !== 'production') {
|
|
|
+ isUpdatingChildComponent = true
|
|
|
+ }
|
|
|
+
|
|
|
// determine whether component has slot children
|
|
|
// we need to do this before overwriting $options._renderChildren
|
|
|
const hasChildren = !!(
|
|
|
@@ -218,17 +223,21 @@ export function updateChildComponent (
|
|
|
|
|
|
vm.$options._parentVnode = parentVnode
|
|
|
vm.$vnode = parentVnode // update vm's placeholder node without re-render
|
|
|
+
|
|
|
if (vm._vnode) { // update child tree's parent
|
|
|
vm._vnode.parent = parentVnode
|
|
|
}
|
|
|
vm.$options._renderChildren = renderChildren
|
|
|
|
|
|
+ // update $attrs and $listensers hash
|
|
|
+ // these are also reactive so they may trigger child update if the child
|
|
|
+ // used them during render
|
|
|
+ vm.$attrs = parentVnode.data && parentVnode.data.attrs
|
|
|
+ vm.$listeners = listeners
|
|
|
+
|
|
|
// update props
|
|
|
if (propsData && vm.$options.props) {
|
|
|
observerState.shouldConvert = false
|
|
|
- if (process.env.NODE_ENV !== 'production') {
|
|
|
- observerState.isSettingProps = true
|
|
|
- }
|
|
|
const props = vm._props
|
|
|
const propKeys = vm.$options._propKeys || []
|
|
|
for (let i = 0; i < propKeys.length; i++) {
|
|
|
@@ -236,12 +245,10 @@ export function updateChildComponent (
|
|
|
props[key] = validateProp(key, vm.$options.props, propsData, vm)
|
|
|
}
|
|
|
observerState.shouldConvert = true
|
|
|
- if (process.env.NODE_ENV !== 'production') {
|
|
|
- observerState.isSettingProps = false
|
|
|
- }
|
|
|
// keep a copy of raw propsData
|
|
|
vm.$options.propsData = propsData
|
|
|
}
|
|
|
+
|
|
|
// update listeners
|
|
|
if (listeners) {
|
|
|
const oldListeners = vm.$options._parentListeners
|
|
|
@@ -253,6 +260,10 @@ export function updateChildComponent (
|
|
|
vm.$slots = resolveSlots(renderChildren, parentVnode.context)
|
|
|
vm.$forceUpdate()
|
|
|
}
|
|
|
+
|
|
|
+ if (process.env.NODE_ENV !== 'production') {
|
|
|
+ isUpdatingChildComponent = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function isInInactiveTree (vm) {
|