File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed
test/unit/features/component Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -368,7 +368,12 @@ function genScopedSlots (
368368 // for example if the slot contains dynamic names, has v-if or v-for on them...
369369 let needsForceUpdate = Object . keys ( slots ) . some ( key => {
370370 const slot = slots [ key ]
371- return slot . slotTargetDynamic || slot . if || slot . for
371+ return (
372+ slot . slotTargetDynamic ||
373+ slot . if ||
374+ slot . for ||
375+ containsSlotChild ( slot ) // is passing down slot from parent which may be dynamic
376+ )
372377 } )
373378 // OR when it is inside another scoped slot (the reactivity is disconnected)
374379 // #9438
@@ -390,6 +395,16 @@ function genScopedSlots (
390395 } ]${ needsForceUpdate ? `,true` : `` } )`
391396}
392397
398+ function containsSlotChild ( el : ASTNode ) : boolean {
399+ if ( el . type === 1 ) {
400+ if ( el . tag === 'slot' ) {
401+ return true
402+ }
403+ return el . children . some ( containsSlotChild )
404+ }
405+ return false
406+ }
407+
393408function genScopedSlot (
394409 el : ASTElement ,
395410 state : CodegenState
Original file line number Diff line number Diff line change @@ -1104,7 +1104,7 @@ describe('Component scoped slot', () => {
11041104 expect ( vm . $el . textContent ) . toBe ( 'hello' )
11051105 } )
11061106
1107- it ( 'should not cache scoped slot normalzation when there are a mix of normal and scoped slots' , done => {
1107+ it ( 'should not cache scoped slot normalization when there are a mix of normal and scoped slots' , done => {
11081108 const foo = {
11091109 template : `<div><slot name="foo" /> <slot name="bar" /></div>`
11101110 }
@@ -1144,4 +1144,31 @@ describe('Component scoped slot', () => {
11441144
11451145 expect ( vm . $el . textContent ) . toBe ( 'foo bar' )
11461146 } )
1147+
1148+ it ( 'should not skip updates when a scoped slot contains parent <slot/> content' , done => {
1149+ const inner = {
1150+ template : `<div><slot/></div>`
1151+ }
1152+
1153+ const wrapper = {
1154+ template : `<inner v-slot><slot/></inner>` ,
1155+ components : { inner }
1156+ }
1157+
1158+ const vm = new Vue ( {
1159+ data ( ) {
1160+ return {
1161+ ok : true
1162+ }
1163+ } ,
1164+ components : { wrapper } ,
1165+ template : `<wrapper><div>{{ ok ? 'foo' : 'bar' }}</div></wrapper>`
1166+ } ) . $mount ( )
1167+
1168+ expect ( vm . $el . textContent ) . toBe ( 'foo' )
1169+ vm . ok = false
1170+ waitForUpdate ( ( ) => {
1171+ expect ( vm . $el . textContent ) . toBe ( 'bar' )
1172+ } ) . then ( done )
1173+ } )
11471174} )
You can’t perform that action at this time.
0 commit comments