File tree Expand file tree Collapse file tree 4 files changed +30
-42
lines changed
platforms/web/runtime/components Expand file tree Collapse file tree 4 files changed +30
-42
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export default {
13
13
render ( ) {
14
14
const rawChild = this . child
15
15
const realChild = getRealChild ( this . child )
16
- if ( realChild . componentOptions ) {
16
+ if ( realChild && realChild . componentOptions ) {
17
17
const cid = realChild . componentOptions . Ctor . cid
18
18
if ( this . cache [ cid ] ) {
19
19
const child = realChild . child = this . cache [ cid ] . child
Original file line number Diff line number Diff line change 1
1
import { warn } from 'core/util/index'
2
2
import { noop , camelize } from 'shared/util'
3
- import { leave } from 'web/runtime/modules/transition'
4
3
import { getRealChild , mergeVNodeHook } from 'core/vdom/helpers'
5
4
6
5
export default {
@@ -60,20 +59,13 @@ export default {
60
59
const oldChild = getRealChild ( oldRawChild )
61
60
if ( mode && oldChild && oldChild . data && oldChild . key !== child . key ) {
62
61
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 - k e e p - a l i v e $ / . test ( rawChild . tag )
67
+ ? h ( 'keep-alive' )
68
+ : null
77
69
} else if ( mode === 'in-out' ) {
78
70
let delayedLeave
79
71
const performLeave = ( ) => { delayedLeave ( ) }
Original file line number Diff line number Diff line change @@ -81,23 +81,21 @@ describe('Component keep-alive', () => {
81
81
let next
82
82
const vm = new Vue ( {
83
83
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 >
91
91
</div>` ,
92
92
data : {
93
93
view : 'one'
94
94
} ,
95
95
components,
96
- transitions : {
97
- test : {
98
- afterLeave ( ) {
99
- next ( )
100
- }
96
+ methods : {
97
+ afterLeave ( ) {
98
+ next ( )
101
99
}
102
100
}
103
101
} ) . $mount ( el )
@@ -170,23 +168,21 @@ describe('Component keep-alive', () => {
170
168
let next
171
169
const vm = new Vue ( {
172
170
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 >
180
178
</div>` ,
181
179
data : {
182
180
view : 'one'
183
181
} ,
184
182
components,
185
- transitions : {
186
- test : {
187
- afterEnter ( ) {
188
- next ( )
189
- }
183
+ methods : {
184
+ afterEnter ( ) {
185
+ next ( )
190
186
}
191
187
}
192
188
} ) . $mount ( el )
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ import Vue from 'vue'
3
3
describe ( 'Global API: assets' , ( ) => {
4
4
const Test = Vue . extend ( )
5
5
6
- it ( 'directive / transition / filters' , ( ) => {
7
- const assets = [ 'directive' , 'transition' , ' filter']
6
+ it ( 'directive / filters' , ( ) => {
7
+ const assets = [ 'directive' , 'filter' ]
8
8
assets . forEach ( function ( type ) {
9
9
const def = { }
10
10
Test [ type ] ( 'test' , def )
You can’t perform that action at this time.
0 commit comments