diff --git a/src/core/components/keep-alive.js b/src/core/components/keep-alive.js
index fb4cf1e883b..e9ce1e8957d 100644
--- a/src/core/components/keep-alive.js
+++ b/src/core/components/keep-alive.js
@@ -113,7 +113,7 @@ export default {
keys.push(key)
// prune oldest entry
if (this.max && keys.length > parseInt(this.max)) {
- pruneCacheEntry(cache, keys[0], keys, this._vnode)
+ pruneCacheEntry(cache, keys[0], keys, vnode)
}
}
diff --git a/test/unit/features/component/component-keep-alive.spec.js b/test/unit/features/component/component-keep-alive.spec.js
index a2cdf6a4f09..269c8317b53 100644
--- a/test/unit/features/component/component-keep-alive.spec.js
+++ b/test/unit/features/component/component-keep-alive.spec.js
@@ -572,6 +572,56 @@ describe('Component keep-alive', () => {
}).then(done)
})
+ // #10015
+ it('prune cache on max set 1', done => {
+ const spyA = jasmine.createSpy()
+ const spyB = jasmine.createSpy()
+ const spyAD = jasmine.createSpy()
+ const spyBD = jasmine.createSpy()
+
+ function assertCount (calls) {
+ expect([
+ spyA.calls.count(),
+ spyAD.calls.count(),
+ spyB.calls.count(),
+ spyBD.calls.count(),
+ ]).toEqual(calls)
+ }
+
+ const vm = new Vue({
+ template: `
+