Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 725d31b

Browse files
committed
fix(compat): correctly handle undefined in slots
1 parent fe13503 commit 725d31b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/vue.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,20 @@ if (isVue3) {
4949
const originalRender = definition.render
5050
definition.__alreadyPatched = true
5151
definition.render = function(h) {
52-
const patchedH = function(tag, dataObjOrChildren, ...rest) {
52+
const patchedH = function(tag, dataObjOrChildren, rawSlots) {
53+
const slots =
54+
rawSlots === undefined
55+
? []
56+
: [Array.isArray(rawSlots) ? rawSlots.filter(Boolean) : rawSlots]
57+
5358
const isTag = typeof tag === 'string' && !KNOWN_COMPONENTS.includes(tag)
5459
const isSecondArgumentDataObject =
5560
dataObjOrChildren &&
5661
typeof dataObjOrChildren === 'object' &&
5762
!Array.isArray(dataObjOrChildren)
5863

5964
if (!isSecondArgumentDataObject) {
60-
return h(tag, dataObjOrChildren, ...rest)
65+
return h(tag, dataObjOrChildren, ...slots)
6166
}
6267

6368
const { attrs, props, ...restData } = dataObjOrChildren
@@ -70,7 +75,7 @@ if (isVue3) {
7075
// terrible workaround to fix router-link rendering with compat vue-router
7176
normalizedData.scopedSlots = { $hasNormal: () => {} }
7277
}
73-
return h(tag, normalizedData, ...rest)
78+
return h(tag, normalizedData, ...slots)
7479
}
7580

7681
if (definition.functional) {

0 commit comments

Comments
 (0)