@@ -8,35 +8,40 @@ import { currentInstance, setCurrentInstance } from 'v3/currentInstance'
88
99export function normalizeScopedSlots (
1010 ownerVm : Component ,
11- slots : { [ key : string ] : Function } | void ,
12- normalSlots : { [ key : string ] : VNode [ ] }
11+ scopedSlots : { [ key : string ] : Function } | undefined ,
12+ normalSlots : { [ key : string ] : VNode [ ] } ,
13+ prevScopedSlots ?: { [ key : string ] : Function }
1314) : any {
1415 let res
15- const prevSlots = ownerVm . $scopedSlots
1616 const hasNormalSlots = Object . keys ( normalSlots ) . length > 0
17- const isStable = slots ? ! ! slots . $stable : ! hasNormalSlots
18- const key = slots && slots . $key
19- if ( ! slots ) {
17+ const isStable = scopedSlots ? ! ! scopedSlots . $stable : ! hasNormalSlots
18+ const key = scopedSlots && scopedSlots . $key
19+ if ( ! scopedSlots ) {
2020 res = { }
21- } else if ( slots . _normalized ) {
21+ } else if ( scopedSlots . _normalized ) {
2222 // fast path 1: child component re-render only, parent did not change
23- return slots . _normalized
23+ return scopedSlots . _normalized
2424 } else if (
2525 isStable &&
26- prevSlots &&
27- prevSlots !== emptyObject &&
28- key === prevSlots . $key &&
26+ prevScopedSlots &&
27+ prevScopedSlots !== emptyObject &&
28+ key === prevScopedSlots . $key &&
2929 ! hasNormalSlots &&
30- ! prevSlots . $hasNormal
30+ ! prevScopedSlots . $hasNormal
3131 ) {
3232 // fast path 2: stable scoped slots w/ no normal slots to proxy,
3333 // only need to normalize once
34- return prevSlots
34+ return prevScopedSlots
3535 } else {
3636 res = { }
37- for ( const key in slots ) {
38- if ( slots [ key ] && key [ 0 ] !== '$' ) {
39- res [ key ] = normalizeScopedSlot ( ownerVm , normalSlots , key , slots [ key ] )
37+ for ( const key in scopedSlots ) {
38+ if ( scopedSlots [ key ] && key [ 0 ] !== '$' ) {
39+ res [ key ] = normalizeScopedSlot (
40+ ownerVm ,
41+ normalSlots ,
42+ key ,
43+ scopedSlots [ key ]
44+ )
4045 }
4146 }
4247 }
@@ -48,8 +53,8 @@ export function normalizeScopedSlots(
4853 }
4954 // avoriaz seems to mock a non-extensible $scopedSlots object
5055 // and when that is passed down this would cause an error
51- if ( slots && Object . isExtensible ( slots ) ) {
52- slots . _normalized = res
56+ if ( scopedSlots && Object . isExtensible ( scopedSlots ) ) {
57+ scopedSlots . _normalized = res
5358 }
5459 def ( res , '$stable' , isStable )
5560 def ( res , '$key' , key )
0 commit comments