fix(keep-alive): fix keep-alive with scopeId/fallthrough attrs
fix #1511
This commit is contained in:
@@ -14,7 +14,8 @@ import {
|
||||
ComponentPublicInstance,
|
||||
Ref,
|
||||
cloneVNode,
|
||||
provide
|
||||
provide,
|
||||
withScopeId
|
||||
} from '@vue/runtime-test'
|
||||
import { KeepAliveProps } from '../../src/components/KeepAlive'
|
||||
|
||||
@@ -655,4 +656,30 @@ describe('KeepAlive', () => {
|
||||
expect(spyMounted).toHaveBeenCalledTimes(3)
|
||||
expect(spyUnmounted).toHaveBeenCalledTimes(4)
|
||||
})
|
||||
|
||||
// #1513
|
||||
test('should work with cloned root due to scopeId / fallthrough attrs', async () => {
|
||||
const viewRef = ref('one')
|
||||
const instanceRef = ref<any>(null)
|
||||
const withId = withScopeId('foo')
|
||||
const App = {
|
||||
__scopeId: 'foo',
|
||||
render: withId(() => {
|
||||
return h(KeepAlive, null, {
|
||||
default: () => h(views[viewRef.value], { ref: instanceRef })
|
||||
})
|
||||
})
|
||||
}
|
||||
render(h(App), root)
|
||||
expect(serializeInner(root)).toBe(`<div foo>one</div>`)
|
||||
instanceRef.value.msg = 'changed'
|
||||
await nextTick()
|
||||
expect(serializeInner(root)).toBe(`<div foo>changed</div>`)
|
||||
viewRef.value = 'two'
|
||||
await nextTick()
|
||||
expect(serializeInner(root)).toBe(`<div foo>two</div>`)
|
||||
viewRef.value = 'one'
|
||||
await nextTick()
|
||||
expect(serializeInner(root)).toBe(`<div foo>changed</div>`)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user