.assert.cssClassPresent('.view.home', 'fade-enter-active')
.waitForElementNotPresent('.view.home.fade-enter-active', TIMEOUT)
+ .click('li:nth-child(5) a')
+ .assert.cssClassPresent('.view.home', 'fade-leave-active')
+ .waitForElementNotPresent('.view.home', TIMEOUT)
+ .click('li:nth-child(2) a')
+ .assert.cssClassPresent('.view.parent', 'fade-enter-active')
+
.end()
},
}
<div class="parent">
<h2>Parent</h2>
{{ transitionName }}
- <router-view class="child-view" v-slot="{ Component }">
+ <router-view class="child-view" v-slot="{ Component, route }">
<transition :name="transitionName">
<component :is="Component" />
</transition>
<li><router-link to="/parent">/parent</router-link></li>
<li><router-link to="/parent/foo">/parent/foo</router-link></li>
<li><router-link to="/parent/bar">/parent/bar</router-link></li>
+ <li><router-link to="/not-found">Not existing</router-link></li>
</ul>
<router-view class="view" v-slot="{ Component }">
<transition name="fade" mode="out-in">
setup(props, { attrs, slots }) {
__DEV__ && warnDeprecatedUsage()
- const route = inject(routeLocationKey)!
+ const injectedRoute = inject(routeLocationKey)!
const depth = inject(viewDepthKey, 0)
const matchedRouteRef = computed(
- () => (props.route || route).matched[depth]
+ () => (props.route || injectedRoute).matched[depth]
)
provide(viewDepthKey, depth + 1)
const viewRef = ref<ComponentPublicInstance>()
return () => {
+ const route = props.route || injectedRoute
const matchedRoute = matchedRouteRef.value
- if (!matchedRoute) {
- return null
- }
+ const ViewComponent = matchedRoute && matchedRoute.components[props.name]
- const ViewComponent = matchedRoute.components[props.name]
if (!ViewComponent) {
- return null
+ return slots.default
+ ? slots.default({ Component: ViewComponent, route })
+ : null
}
// props from route configration
// pass the vnode to the slot as a prop.
// h and <component :is="..."> both accept vnodes
slots.default
- ? slots.default({ Component: component, route: matchedRoute })
+ ? slots.default({ Component: component, route })
: component
)
}