expect('can no longer be used directly inside').toHaveBeenWarned()
})
+ it('does not warn if RouterView is not a direct-child of transition', async () => {
+ const route = createMockedRoute(routes.root)
+ mount(
+ {
+ template: `
+ <transition>
+ <div>
+ <router-view/>
+ </div>
+ </transition>
+ `,
+ },
+ {
+ props: {},
+ global: {
+ stubs: {
+ transition: false,
+ },
+ provide: route.provides,
+ components: { RouterView },
+ },
+ }
+ )
+ expect('can no longer be used directly inside').not.toHaveBeenWarned()
+ })
+
it('warns if Transition wraps a RouterView', () => {
const route = createMockedRoute(routes.root)
const wrapper = mount(
watch,
Slot,
VNode,
+ Component,
} from 'vue'
import {
RouteLocationNormalized,
function warnDeprecatedUsage() {
const instance = getCurrentInstance()!
const parentName = instance.parent && instance.parent.type.name
+ const parentSubTreeType =
+ instance.parent && instance.parent.subTree && instance.parent.subTree.type
if (
parentName &&
- (parentName === 'KeepAlive' || parentName.includes('Transition'))
+ (parentName === 'KeepAlive' || parentName.includes('Transition')) &&
+ typeof parentSubTreeType === 'object' &&
+ (parentSubTreeType as Component).name === 'RouterView'
) {
const comp = parentName === 'KeepAlive' ? 'keep-alive' : 'transition'
warn(