File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed
src/platforms/web/runtime/modules
test/unit/features/transition Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -181,12 +181,12 @@ export function leave (vnode: VNodeWithData, rm: Function) {
181181 }
182182
183183 const data = resolveTransition ( vnode . data . transition )
184- if ( isUndef ( data ) ) {
184+ if ( isUndef ( data ) || el . nodeType !== 1 ) {
185185 return rm ( )
186186 }
187187
188188 /* istanbul ignore if */
189- if ( isDef ( el . _leaveCb ) || el . nodeType !== 1 ) {
189+ if ( isDef ( el . _leaveCb ) ) {
190190 return
191191 }
192192
Original file line number Diff line number Diff line change @@ -1081,5 +1081,47 @@ if (!isIE9) {
10811081 } ) . then ( done )
10821082 } )
10831083 } )
1084+
1085+ // #6687
1086+ it ( 'transition on child components with empty root node' , done => {
1087+ const vm = new Vue ( {
1088+ template : `
1089+ <div>
1090+ <transition mode="out-in">
1091+ <component class="test" :is="view"></component>
1092+ </transition>
1093+ </div>
1094+ ` ,
1095+ data : { view : 'one' } ,
1096+ components : {
1097+ 'one' : {
1098+ template : '<div v-if="false">one</div>'
1099+ } ,
1100+ 'two' : {
1101+ template : '<div>two</div>'
1102+ }
1103+ }
1104+ } ) . $mount ( el )
1105+
1106+ // should not apply transition on initial render by default
1107+ expect ( vm . $el . innerHTML ) . toBe ( '<!---->' )
1108+ vm . view = 'two'
1109+ waitForUpdate ( ( ) => {
1110+ expect ( vm . $el . innerHTML ) . toBe ( '<div class="test v-enter v-enter-active">two</div>' )
1111+ } ) . thenWaitFor ( nextFrame ) . then ( ( ) => {
1112+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-enter-active v-enter-to' )
1113+ } ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
1114+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test' )
1115+ vm . view = 'one'
1116+ } ) . then ( ( ) => {
1117+ // incoming comment node is appended instantly because it doesn't have
1118+ // data and therefore doesn't go through the transition module.
1119+ expect ( vm . $el . innerHTML ) . toBe ( '<div class="test v-leave v-leave-active">two</div><!---->' )
1120+ } ) . thenWaitFor ( nextFrame ) . then ( ( ) => {
1121+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-leave-active v-leave-to' )
1122+ } ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
1123+ expect ( vm . $el . innerHTML ) . toBe ( '<!---->' )
1124+ } ) . then ( done )
1125+ } )
10841126 } )
10851127}
You can’t perform that action at this time.
0 commit comments