@@ -12,7 +12,6 @@ import {
12
12
ShapeFlags ,
13
13
SlotFlags ,
14
14
def ,
15
- extend ,
16
15
isArray ,
17
16
isFunction ,
18
17
} from '@vue/shared'
@@ -161,6 +160,22 @@ const normalizeVNodeSlots = (
161
160
instance . slots . default = ( ) => normalized
162
161
}
163
162
163
+ const assignSlots = (
164
+ slots : InternalSlots ,
165
+ children : Slots ,
166
+ optimized : boolean ,
167
+ ) => {
168
+ for ( const key in children ) {
169
+ // #2893
170
+ // when rendering the optimized slots by manually written render function,
171
+ // do not copy the `slots._` compiler flag so that `renderSlot` creates
172
+ // slot Fragment with BAIL patchFlag to force full updates
173
+ if ( optimized || key !== '_' ) {
174
+ slots [ key ] = children [ key ]
175
+ }
176
+ }
177
+ }
178
+
164
179
export const initSlots = (
165
180
instance : ComponentInternalInstance ,
166
181
children : VNodeNormalizedChildren ,
@@ -170,16 +185,10 @@ export const initSlots = (
170
185
if ( instance . vnode . shapeFlag & ShapeFlags . SLOTS_CHILDREN ) {
171
186
const type = ( children as RawSlots ) . _
172
187
if ( type ) {
173
- extend ( slots , children as InternalSlots )
188
+ assignSlots ( slots , children as Slots , optimized )
174
189
// make compiler marker non-enumerable
175
190
if ( optimized ) {
176
191
def ( slots , '_' , type , true )
177
- } else {
178
- // #2893
179
- // when rendering the optimized slots by manually written render function,
180
- // we need to delete the `slots._` flag if necessary to make subsequent
181
- // updates reliable, i.e. let the `renderSlot` create the bailed Fragment
182
- delete slots . _
183
192
}
184
193
} else {
185
194
normalizeObjectSlots ( children as RawSlots , slots , instance )
@@ -204,7 +213,7 @@ export const updateSlots = (
204
213
if ( __DEV__ && isHmrUpdating ) {
205
214
// Parent was HMR updated so slot content may have changed.
206
215
// force update slots and mark instance for hmr as well
207
- extend ( slots , children as Slots )
216
+ assignSlots ( slots , children as Slots , optimized )
208
217
trigger ( instance , TriggerOpTypes . SET , '$slots' )
209
218
} else if ( optimized && type === SlotFlags . STABLE ) {
210
219
// compiled AND stable.
@@ -213,7 +222,7 @@ export const updateSlots = (
213
222
} else {
214
223
// compiled but dynamic (v-if/v-for on slots) - update slots, but skip
215
224
// normalization.
216
- extend ( slots , children as Slots )
225
+ assignSlots ( slots , children as Slots , optimized )
217
226
}
218
227
} else {
219
228
needDeletionCheck = ! ( children as RawSlots ) . $stable
0 commit comments