File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed
test/unit/features/component Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -343,11 +343,14 @@ function genScopedSlot (
343343 if ( el . for && ! el . forProcessed ) {
344344 return genForScopedSlot ( key , el , state )
345345 }
346- return `{key: ${ key } ,fn: function(${ String ( el . slotScope ) } ){` +
346+ const fn = ` function(${ String ( el . slotScope ) } ){` +
347347 `return ${ el . tag === 'template'
348- ? genChildren ( el , state ) || 'void 0'
348+ ? el . if
349+ ? `${ el . if } ?${ genChildren ( el , state ) || 'undefined' } :undefined`
350+ : genChildren ( el , state ) || 'undefined'
349351 : genElement ( el , state )
350- } }}`
352+ } }`
353+ return `{key:${ key } ,fn:${ fn } }`
351354}
352355
353356function genForScopedSlot (
Original file line number Diff line number Diff line change @@ -557,4 +557,40 @@ describe('Component scoped slot', () => {
557557 expect ( vm . $el . innerHTML ) . toBe ( '<span>world foo</span> <span>world bar</span> <span>world abc</span>' )
558558 } ) . then ( done )
559559 } )
560+
561+ // #6725
562+ it ( 'scoped slot with v-if' , done => {
563+ const vm = new Vue ( {
564+ data : {
565+ ok : false
566+ } ,
567+ template : `
568+ <test>
569+ <template v-if="ok" slot-scope="foo">
570+ <p>{{ foo.text }}</p>
571+ </template>
572+ </test>
573+ ` ,
574+ components : {
575+ test : {
576+ data ( ) {
577+ return { msg : 'hello' }
578+ } ,
579+ template : `
580+ <div>
581+ <slot :text="msg">
582+ <span>{{ msg }} fallback</span>
583+ </slot>
584+ </div>
585+ `
586+ }
587+ }
588+ } ) . $mount ( )
589+ expect ( vm . $el . innerHTML ) . toBe ( '<span>hello fallback</span>' )
590+
591+ vm . ok = true
592+ waitForUpdate ( ( ) => {
593+ expect ( vm . $el . innerHTML ) . toBe ( '<p>hello</p>' )
594+ } ) . then ( done )
595+ } )
560596} )
You can’t perform that action at this time.
0 commit comments