Permalink
Browse files

fix(transition-group): fix activeInstance regression

fix #9151
  • Loading branch information...
yyx990803 committed Dec 5, 2018
1 parent 0ed0aad commit 8a2dbf50105ea729125a42fecfe2c2f0371d7836
Showing with 13 additions and 3 deletions.
  1. +10 −3 src/core/instance/lifecycle.js
  2. +3 −0 src/platforms/web/runtime/components/transition-group.js
@@ -21,6 +21,14 @@ import {
export let activeInstance: any = null
export let isUpdatingChildComponent: boolean = false
export function setActiveInstance(vm: Component) {
const prevActiveInstance = activeInstance
activeInstance = vm
return () => {
activeInstance = prevActiveInstance
}
}
export function initLifecycle (vm: Component) {
const options = vm.$options
@@ -52,8 +60,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
const vm: Component = this
const prevEl = vm.$el
const prevVnode = vm._vnode
const prevActiveInstance = activeInstance
activeInstance = vm
const restoreActiveInstance = setActiveInstance(vm)
vm._vnode = vnode
// Vue.prototype.__patch__ is injected in entry points
// based on the rendering backend used.
@@ -64,7 +71,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
// updates
vm.$el = vm.__patch__(prevVnode, vnode)
}
activeInstance = prevActiveInstance
restoreActiveInstance()
// update __vue__ reference
if (prevEl) {
prevEl.__vue__ = null
@@ -14,6 +14,7 @@
import { warn, extend } from 'core/util/index'
import { addClass, removeClass } from '../class-util'
import { transitionProps, extractTransitionData } from './transition'
import { setActiveInstance } from 'core/instance/lifecycle'
import {
hasTransition,
@@ -36,6 +37,7 @@ export default {
beforeMount () {
const update = this._update
this._update = (vnode, hydrating) => {
const restoreActiveInstance = setActiveInstance(this)
// force removing pass
this.__patch__(
this._vnode,
@@ -44,6 +46,7 @@ export default {
true // removeOnly (!important, avoids unnecessary moves)
)
this._vnode = this.kept
restoreActiveInstance()
update.call(this, vnode, hydrating)
}
},

0 comments on commit 8a2dbf5

Please sign in to comment.