File tree 2 files changed +13
-4
lines changed
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,8 @@ export function renderMixin (Vue: Class<Component>) {
73
73
if ( _parentVnode ) {
74
74
vm . $scopedSlots = normalizeScopedSlots (
75
75
_parentVnode . data . scopedSlots ,
76
- vm . $slots
76
+ vm . $slots ,
77
+ vm . $scopedSlots
77
78
)
78
79
}
79
80
Original file line number Diff line number Diff line change 2
2
3
3
import { def } from 'core/util/lang'
4
4
import { normalizeChildren } from 'core/vdom/helpers/normalize-children'
5
+ import { emptyObject } from 'shared/util'
5
6
6
7
export function normalizeScopedSlots (
7
8
slots : { [ key : string ] : Function } | void ,
8
- normalSlots : { [ key : string ] : Array < VNode > }
9
+ normalSlots : { [ key : string ] : Array < VNode > } ,
10
+ prevSlots ?: { [ key : string ] : Function } | void
9
11
) : any {
10
12
let res
11
13
if ( ! slots ) {
12
14
res = { }
13
15
} else if ( slots . _normalized ) {
14
- return slots
16
+ // fast path 1: child component re-render only, parent did not change
17
+ return slots . _normalized
18
+ } else if ( slots . $stable && prevSlots && prevSlots !== emptyObject ) {
19
+ // fast path 2: stable scoped slots, only need to normalize once
20
+ return prevSlots
15
21
} else {
16
22
res = { }
17
23
for ( const key in slots ) {
@@ -26,7 +32,9 @@ export function normalizeScopedSlots (
26
32
res [ key ] = proxyNormalSlot ( normalSlots , key )
27
33
}
28
34
}
29
- def ( res , '_normalized' , true )
35
+ if ( slots ) {
36
+ ( slots : any ) . _normalized = res
37
+ }
30
38
def ( res , '$stable' , slots ? ! ! slots . $stable : true )
31
39
return res
32
40
}
You can’t perform that action at this time.
0 commit comments