Closed
Description
Version
2.6.10
Reproduction link
https://jsfiddle.net/p0te9vL3/
Steps to reproduce
- Open dev tools to see console
- Cycle through the routes
- View console and observe lifecycle hook logging
What is expected?
I'd expect once the max
cache is reached (in the example case of 1), the component that gets pruned also gets destroyed. In the documentation it states (emphasis mine):
max
The maximum number of component instances to cache. Once this number is reached, the cached component instance that was least recently accessed will be destroyed before creating a new instance.
What is actually happening?
The pruned component is never destroyed, it's just removed from the cache. In the example, the beforeDestroy
hook is never called.
Related code:
vue/src/core/components/keep-alive.js
Lines 37 to 49 in 636c9b4