Skip to content

Commit ef31193

Browse files
committed
all tests pass for new transition API
1 parent bb3fe8e commit ef31193

File tree

4 files changed

+30
-42
lines changed

4 files changed

+30
-42
lines changed

src/core/components/keep-alive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
render () {
1414
const rawChild = this.child
1515
const realChild = getRealChild(this.child)
16-
if (realChild.componentOptions) {
16+
if (realChild && realChild.componentOptions) {
1717
const cid = realChild.componentOptions.Ctor.cid
1818
if (this.cache[cid]) {
1919
const child = realChild.child = this.cache[cid].child

src/platforms/web/runtime/components/transition.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { warn } from 'core/util/index'
22
import { noop, camelize } from 'shared/util'
3-
import { leave } from 'web/runtime/modules/transition'
43
import { getRealChild, mergeVNodeHook } from 'core/vdom/helpers'
54

65
export default {
@@ -60,20 +59,13 @@ export default {
6059
const oldChild = getRealChild(oldRawChild)
6160
if (mode && oldChild && oldChild.data && oldChild.key !== child.key) {
6261
if (mode === 'out-in') {
63-
if (
64-
!oldChild.elm._leaveCb && // not already leaving
65-
oldChild.data.transition // not already left
66-
) {
67-
leave(oldChild, () => {
68-
// mark left & avoid triggering leave transition again
69-
oldChild.data.transition = null
70-
this.$forceUpdate()
71-
})
72-
}
73-
// return old node if not left yet
74-
if (oldChild.data.transition) {
75-
return oldRawChild
76-
}
62+
// return empty node and queue update when leave finishes
63+
mergeVNodeHook(oldChild.data.transition, 'afterLeave', () => {
64+
this.$forceUpdate()
65+
})
66+
return /\d-keep-alive$/.test(rawChild.tag)
67+
? h('keep-alive')
68+
: null
7769
} else if (mode === 'in-out') {
7870
let delayedLeave
7971
const performLeave = () => { delayedLeave() }

test/unit/features/component/component-keep-alive.spec.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,21 @@ describe('Component keep-alive', () => {
8181
let next
8282
const vm = new Vue({
8383
template: `<div>
84-
<component
85-
:is="view"
86-
class="test"
87-
keep-alive
88-
transition="test"
89-
transition-mode="out-in">
90-
</component>
84+
<transition name="test" mode="out-in" @after-leave="afterLeave">
85+
<component
86+
:is="view"
87+
class="test"
88+
keep-alive>
89+
</component>
90+
<transition>
9191
</div>`,
9292
data: {
9393
view: 'one'
9494
},
9595
components,
96-
transitions: {
97-
test: {
98-
afterLeave () {
99-
next()
100-
}
96+
methods: {
97+
afterLeave () {
98+
next()
10199
}
102100
}
103101
}).$mount(el)
@@ -170,23 +168,21 @@ describe('Component keep-alive', () => {
170168
let next
171169
const vm = new Vue({
172170
template: `<div>
173-
<component
174-
:is="view"
175-
class="test"
176-
keep-alive
177-
transition="test"
178-
transition-mode="in-out">
179-
</component>
171+
<transition name="test" mode="in-out" @after-enter="afterEnter">
172+
<component
173+
:is="view"
174+
class="test"
175+
keep-alive>
176+
</component>
177+
</transition>
180178
</div>`,
181179
data: {
182180
view: 'one'
183181
},
184182
components,
185-
transitions: {
186-
test: {
187-
afterEnter () {
188-
next()
189-
}
183+
methods: {
184+
afterEnter () {
185+
next()
190186
}
191187
}
192188
}).$mount(el)

test/unit/features/global-api/assets.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import Vue from 'vue'
33
describe('Global API: assets', () => {
44
const Test = Vue.extend()
55

6-
it('directive / transition / filters', () => {
7-
const assets = ['directive', 'transition', 'filter']
6+
it('directive / filters', () => {
7+
const assets = ['directive', 'filter']
88
assets.forEach(function (type) {
99
const def = {}
1010
Test[type]('test', def)

0 commit comments

Comments
 (0)