File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed
test/unit/features/component Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -375,12 +375,18 @@ function genScopedSlots (
375
375
containsSlotChild ( slot ) // is passing down slot from parent which may be dynamic
376
376
)
377
377
} )
378
- // OR when it is inside another scoped slot (the reactivity is disconnected)
379
- // #9438
378
+ // OR when it is inside another scoped slot or v-for (the reactivity may be
379
+ // disconnected due to the intermediate scope variable)
380
+ // #9438, #9506
381
+ // TODO: this can be further optimized by properly analyzing in-scope bindings
382
+ // and skip force updating ones that do not actually use scope variables.
380
383
if ( ! needsForceUpdate ) {
381
384
let parent = el . parent
382
385
while ( parent ) {
383
- if ( parent . slotScope && parent . slotScope !== emptySlotScopeToken ) {
386
+ if (
387
+ ( parent . slotScope && parent . slotScope !== emptySlotScopeToken ) ||
388
+ parent . for
389
+ ) {
384
390
needsForceUpdate = true
385
391
break
386
392
}
Original file line number Diff line number Diff line change @@ -1171,4 +1171,30 @@ describe('Component scoped slot', () => {
1171
1171
expect ( vm . $el . textContent ) . toBe ( 'bar' )
1172
1172
} ) . then ( done )
1173
1173
} )
1174
+
1175
+ it ( 'should not skip updates for v-slot inside v-for' , done => {
1176
+ const test = {
1177
+ template : `<div><slot></slot></div>`
1178
+ }
1179
+
1180
+ const vm = new Vue ( {
1181
+ template : `
1182
+ <div>
1183
+ <div v-for="i in numbers">
1184
+ <test v-slot>{{ i }}</test>
1185
+ </div>
1186
+ </div>
1187
+ ` ,
1188
+ components : { test } ,
1189
+ data : {
1190
+ numbers : [ 1 ]
1191
+ }
1192
+ } ) . $mount ( )
1193
+
1194
+ expect ( vm . $el . textContent ) . toBe ( `1` )
1195
+ vm . numbers = [ 2 ]
1196
+ waitForUpdate ( ( ) => {
1197
+ expect ( vm . $el . textContent ) . toBe ( `2` )
1198
+ } ) . then ( done )
1199
+ } )
1174
1200
} )
You can’t perform that action at this time.
0 commit comments