Skip to content

Commit 8600d8a

Browse files
committed
fix wait-for with keep-alive (fix vuejs#1150)
1 parent 59c9456 commit 8600d8a

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/directives/component.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ module.exports = {
129129
}
130130
}
131131
}
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) {
134135
this.transition(newComponent, cb)
135136
}
136137
}, this))
@@ -174,11 +175,9 @@ module.exports = {
174175
*/
175176

176177
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
182181
}
183182
if (this.Component) {
184183
// default options
@@ -205,6 +204,16 @@ module.exports = {
205204
}
206205
},
207206

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+
208217
/**
209218
* Teardown the current child, but defers cleanup so
210219
* that we can separate the destroy and removal steps.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy