File tree Expand file tree Collapse file tree
runtime-core/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,12 +148,25 @@ const BaseTransitionImpl: ComponentOptions = {
148148 return
149149 }
150150
151- // warn multiple elements
152- if ( __DEV__ && children . length > 1 ) {
153- warn (
154- '<transition> can only be used on a single element or component. Use ' +
155- '<transition-group> for lists.'
156- )
151+ let child : VNode = children [ 0 ]
152+ if ( children . length > 1 ) {
153+ let hasFound = false
154+ // locate first non-comment child
155+ for ( const c of children ) {
156+ if ( c . type !== Comment ) {
157+ if ( __DEV__ && hasFound ) {
158+ // warn more than one non-comment child
159+ warn (
160+ '<transition> can only be used on a single element or component. ' +
161+ 'Use <transition-group> for lists.'
162+ )
163+ break
164+ }
165+ child = c
166+ hasFound = true
167+ if ( ! __DEV__ ) break
168+ }
169+ }
157170 }
158171
159172 // there's no need to track reactivity for these props so use the raw
@@ -171,8 +184,6 @@ const BaseTransitionImpl: ComponentOptions = {
171184 warn ( `invalid <transition> mode: ${ mode } ` )
172185 }
173186
174- // at this point children has a guaranteed length of 1.
175- const child = children [ 0 ]
176187 if ( state . isLeaving ) {
177188 return emptyPlaceholder ( child )
178189 }
Original file line number Diff line number Diff line change @@ -2039,7 +2039,7 @@ describe('e2e: Transition', () => {
20392039 template : `
20402040 <div id="container">
20412041 <transition>
2042- <Comp class="test" v-if="toggle">
2042+ <Comp class="test" v-if="toggle">
20432043 <div>content</div>
20442044 </Comp>
20452045 </transition>
You can’t perform that action at this time.
0 commit comments