mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-21 07:59:33 +00:00
fix(vue-app): resolve leave transition on child routes (#6803)
This commit is contained in:
parent
af75aa86e1
commit
c9beac3c7b
@ -107,14 +107,19 @@ function mapTransitions (Components, to, from) {
|
|||||||
const transition = componentOption(component, 'transition', to, from) || {}
|
const transition = componentOption(component, 'transition', to, from) || {}
|
||||||
return (typeof transition === 'string' ? { name: transition } : transition)
|
return (typeof transition === 'string' ? { name: transition } : transition)
|
||||||
}
|
}
|
||||||
|
const tComponents = [].concat(Components)
|
||||||
|
|
||||||
return Components.map((Component) => {
|
// If leaving a child route to a parent, keep the child leave transition
|
||||||
|
while (from && from.matched.length > tComponents.length) { // eslint-disable-line no-unmodified-loop-condition
|
||||||
|
tComponents.push({})
|
||||||
|
}
|
||||||
|
return tComponents.map((Component, i) => {
|
||||||
// Clone original object to prevent overrides
|
// Clone original object to prevent overrides
|
||||||
const transitions = Object.assign({}, componentTransitions(Component))
|
const transitions = Object.assign({}, componentTransitions(Component))
|
||||||
|
|
||||||
// Combine transitions & prefer `leave` transitions of 'from' route
|
// Combine transitions & prefer `leave` transitions of 'from' route
|
||||||
if (from && from.matched.length && from.matched[0].components.default) {
|
if (from && from.matched[i] && from.matched[i].components.default) {
|
||||||
const fromTransitions = componentTransitions(from.matched[0].components.default)
|
const fromTransitions = componentTransitions(from.matched[i].components.default)
|
||||||
Object.keys(fromTransitions)
|
Object.keys(fromTransitions)
|
||||||
.filter(key => fromTransitions[key] && key.toLowerCase().includes('leave'))
|
.filter(key => fromTransitions[key] && key.toLowerCase().includes('leave'))
|
||||||
.forEach((key) => { transitions[key] = fromTransitions[key] })
|
.forEach((key) => { transitions[key] = fromTransitions[key] })
|
||||||
|
Loading…
Reference in New Issue
Block a user