File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,9 @@ module.exports = {
129
129
}
130
130
}
131
131
}
132
- var newComponent = this . build ( options )
133
- if ( ! waitFor ) {
132
+ var cached = this . getCached ( )
133
+ var newComponent = cached || this . build ( options )
134
+ if ( ! waitFor || cached ) {
134
135
this . transition ( newComponent , cb )
135
136
}
136
137
} , this ) )
@@ -174,11 +175,9 @@ module.exports = {
174
175
*/
175
176
176
177
build : function ( extraOptions ) {
177
- if ( this . keepAlive ) {
178
- var cached = this . cache [ this . Component . cid ]
179
- if ( cached ) {
180
- return cached
181
- }
178
+ var cached = this . getCached ( )
179
+ if ( cached ) {
180
+ return cached
182
181
}
183
182
if ( this . Component ) {
184
183
// default options
@@ -205,6 +204,16 @@ module.exports = {
205
204
}
206
205
} ,
207
206
207
+ /**
208
+ * Try to get a cached instance of the current component.
209
+ *
210
+ * @return {Vue|undefined }
211
+ */
212
+
213
+ getCached : function ( ) {
214
+ return this . keepAlive && this . cache [ this . Component . cid ]
215
+ } ,
216
+
208
217
/**
209
218
* Teardown the current child, but defers cleanup so
210
219
* that we can separate the destroy and removal steps.
You can’t perform that action at this time.
0 commit comments