Skip to content
Permalink
Browse files
keep-alive re-activated component should get updated props (fix #4237)
  • Loading branch information
yyx990803 committed Nov 19, 2016
1 parent cbc1fbc commit b60cd834660f2141e0e574b82dd17c9b474b8a73
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
@@ -154,6 +154,9 @@ function init (vnode: VNodeWithData, hydrating: boolean) {
if (!vnode.child || vnode.child._isDestroyed) {
const child = vnode.child = createComponentInstanceForVnode(vnode, activeInstance)
child.$mount(hydrating ? vnode.elm : undefined, hydrating)
} else if (vnode.data.keepAlive) {
// kept-alive components, treat as a patch
prepatch(vnode, vnode)
}
}

@@ -107,6 +107,38 @@ describe('Component keep-alive', () => {
}).then(done)
})

// #4237
it('should update latest props/listners for a re-activated component', done => {
const one = {
props: ['prop'],
template: `<div>one {{ prop }}</div>`
}
const two = {
props: ['prop'],
template: `<div>two {{ prop }}</div>`
}
const vm = new Vue({
data: { view: 'one', n: 1 },
template: `
<div>
<keep-alive>
<component :is="view" :prop="n"></component>
</keep-alive>
</div>
`,
components: { one, two }
}).$mount()

expect(vm.$el.textContent).toBe('one 1')
vm.n++
waitForUpdate(() => {
expect(vm.$el.textContent).toBe('one 2')
vm.view = 'two'
}).then(() => {
expect(vm.$el.textContent).toBe('two 2')
}).then(done)
})

if (!isIE9) {
it('with transition-mode out-in', done => {
let next

0 comments on commit b60cd83

Please sign in to comment.