mirror of https://github.com/vuejs/core.git
Merge 8026607be1
into 56be3dd4db
This commit is contained in:
commit
75397a9623
|
@ -683,6 +683,16 @@ describe('KeepAlive', () => {
|
|||
await nextTick()
|
||||
assertHookCalls(one, [2, 2, 1, 1, 1])
|
||||
assertHookCalls(two, [1, 1, 1, 1, 0])
|
||||
|
||||
includeRef.value = ''
|
||||
await nextTick()
|
||||
assertHookCalls(one, [2, 2, 1, 1, 1])
|
||||
assertHookCalls(two, [1, 1, 1, 1, 1])
|
||||
|
||||
viewRef.value = 'two'
|
||||
await nextTick()
|
||||
assertHookCalls(one, [2, 2, 1, 1, 2])
|
||||
assertHookCalls(two, [2, 2, 1, 1, 1])
|
||||
})
|
||||
|
||||
test('on exclude change', async () => {
|
||||
|
@ -702,6 +712,16 @@ describe('KeepAlive', () => {
|
|||
await nextTick()
|
||||
assertHookCalls(one, [2, 2, 1, 1, 1])
|
||||
assertHookCalls(two, [1, 1, 1, 1, 0])
|
||||
|
||||
excludeRef.value = ''
|
||||
await nextTick()
|
||||
assertHookCalls(one, [2, 2, 1, 1, 1])
|
||||
assertHookCalls(two, [1, 1, 1, 1, 0])
|
||||
|
||||
excludeRef.value = 'two'
|
||||
await nextTick()
|
||||
assertHookCalls(one, [2, 2, 1, 1, 1])
|
||||
assertHookCalls(two, [1, 1, 1, 1, 1])
|
||||
})
|
||||
|
||||
test('on include change + view switch', async () => {
|
||||
|
|
|
@ -226,8 +226,8 @@ const KeepAliveImpl: ComponentOptions = {
|
|||
watch(
|
||||
() => [props.include, props.exclude],
|
||||
([include, exclude]) => {
|
||||
include && pruneCache(name => matches(include, name))
|
||||
exclude && pruneCache(name => !matches(exclude, name))
|
||||
include != null && pruneCache(name => matches(include, name))
|
||||
exclude != null && pruneCache(name => !matches(exclude, name))
|
||||
},
|
||||
// prune post-render after `current` has been updated
|
||||
{ flush: 'post', deep: true },
|
||||
|
@ -312,8 +312,8 @@ const KeepAliveImpl: ComponentOptions = {
|
|||
const { include, exclude, max } = props
|
||||
|
||||
if (
|
||||
(include && (!name || !matches(include, name))) ||
|
||||
(exclude && name && matches(exclude, name))
|
||||
(include != null && (!name || !matches(include, name))) ||
|
||||
(exclude != null && name && matches(exclude, name))
|
||||
) {
|
||||
// #11717
|
||||
vnode.shapeFlag &= ~ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
||||
|
|
Loading…
Reference in New Issue