@@ -8,35 +8,40 @@ import { currentInstance, setCurrentInstance } from 'v3/currentInstance'
8
8
9
9
export function normalizeScopedSlots (
10
10
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 }
13
14
) : any {
14
15
let res
15
- const prevSlots = ownerVm . $scopedSlots
16
16
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 ) {
20
20
res = { }
21
- } else if ( slots . _normalized ) {
21
+ } else if ( scopedSlots . _normalized ) {
22
22
// fast path 1: child component re-render only, parent did not change
23
- return slots . _normalized
23
+ return scopedSlots . _normalized
24
24
} else if (
25
25
isStable &&
26
- prevSlots &&
27
- prevSlots !== emptyObject &&
28
- key === prevSlots . $key &&
26
+ prevScopedSlots &&
27
+ prevScopedSlots !== emptyObject &&
28
+ key === prevScopedSlots . $key &&
29
29
! hasNormalSlots &&
30
- ! prevSlots . $hasNormal
30
+ ! prevScopedSlots . $hasNormal
31
31
) {
32
32
// fast path 2: stable scoped slots w/ no normal slots to proxy,
33
33
// only need to normalize once
34
- return prevSlots
34
+ return prevScopedSlots
35
35
} else {
36
36
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
+ )
40
45
}
41
46
}
42
47
}
@@ -48,8 +53,8 @@ export function normalizeScopedSlots(
48
53
}
49
54
// avoriaz seems to mock a non-extensible $scopedSlots object
50
55
// 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
53
58
}
54
59
def ( res , '$stable' , isStable )
55
60
def ( res , '$key' , key )
0 commit comments