Skip to content

Commit cef5fea

Browse files
committed
just use cid as keep-alive key
1 parent 3c20278 commit cef5fea

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/directives/component.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ module.exports = {
4141
}
4242
// component resolution related state
4343
this.pendingComponentCb =
44-
this.componentID =
4544
this.Component = null
4645
// transition related state
4746
this.pendingRemovals = 0
@@ -145,9 +144,8 @@ module.exports = {
145144

146145
resolveComponent: function (id, cb) {
147146
var self = this
148-
this.pendingComponentCb = _.cancellable(function (component) {
149-
self.componentID = id
150-
self.Component = component
147+
this.pendingComponentCb = _.cancellable(function (Component) {
148+
self.Component = Component
151149
cb()
152150
})
153151
this.vm._resolveComponent(id, this.pendingComponentCb)
@@ -177,7 +175,7 @@ module.exports = {
177175

178176
build: function (extraOptions) {
179177
if (this.keepAlive) {
180-
var cached = this.cache[this.componentID]
178+
var cached = this.cache[this.Component.cid]
181179
if (cached) {
182180
return cached
183181
}
@@ -201,7 +199,7 @@ module.exports = {
201199
var parent = this._host || this.vm
202200
var child = parent.$addChild(options, this.Component)
203201
if (this.keepAlive) {
204-
this.cache[this.componentID] = child
202+
this.cache[this.Component.cid] = child
205203
}
206204
return child
207205
}

test/unit/specs/async_component_spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ describe('Async components', function () {
111111
vm.view = 'view-b'
112112
function step1 () {
113113
// called after A resolves, but A should have been
114-
// invalidated so not cotrId should be set
115-
expect(vm._directives[0].componentID).toBe(null)
114+
// invalidated so no Ctor should be set
115+
expect(vm._directives[0].Component).toBe(null)
116116
}
117117
function step2 () {
118118
// B should resolve successfully
@@ -145,8 +145,8 @@ describe('Async components', function () {
145145
vm.$destroy()
146146
function next () {
147147
// called after A resolves, but A should have been
148-
// invalidated so not cotrId should be set
149-
expect(dir.componentID).toBe(null)
148+
// invalidated so no Ctor should be set
149+
expect(dir.Component).toBe(null)
150150
done()
151151
}
152152
})

0 commit comments

Comments
 (0)