fix(transition): handle transition for v-if branches with comment
fix #5675
This commit is contained in:
parent
767d212d20
commit
62eba63172
@ -148,12 +148,25 @@ const BaseTransitionImpl: ComponentOptions = {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// warn multiple elements
|
let child: VNode = children[0]
|
||||||
if (__DEV__ && children.length > 1) {
|
if (children.length > 1) {
|
||||||
warn(
|
let hasFound = false
|
||||||
'<transition> can only be used on a single element or component. Use ' +
|
// locate first non-comment child
|
||||||
'<transition-group> for lists.'
|
for (const c of children) {
|
||||||
)
|
if (c.type !== Comment) {
|
||||||
|
if (__DEV__ && hasFound) {
|
||||||
|
// warn more than one non-comment child
|
||||||
|
warn(
|
||||||
|
'<transition> can only be used on a single element or component. ' +
|
||||||
|
'Use <transition-group> for lists.'
|
||||||
|
)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
child = c
|
||||||
|
hasFound = true
|
||||||
|
if (!__DEV__) break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// there's no need to track reactivity for these props so use the raw
|
// there's no need to track reactivity for these props so use the raw
|
||||||
@ -171,8 +184,6 @@ const BaseTransitionImpl: ComponentOptions = {
|
|||||||
warn(`invalid <transition> mode: ${mode}`)
|
warn(`invalid <transition> mode: ${mode}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// at this point children has a guaranteed length of 1.
|
|
||||||
const child = children[0]
|
|
||||||
if (state.isLeaving) {
|
if (state.isLeaving) {
|
||||||
return emptyPlaceholder(child)
|
return emptyPlaceholder(child)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user