Skip to content

Commit 61e7a78

Browse files
fix(h): fix Teleport rendering error when children is a function
1 parent 02e78f5 commit 61e7a78

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

packages/runtime-core/__tests__/vnode.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ describe('vnode', () => {
120120
})
121121

122122
describe('children normalization', () => {
123-
const nop = vi.fn
124-
125123
test('null', () => {
126124
const vnode = createVNode('p', null, null)
127125
expect(vnode.children).toBe(null)
@@ -145,10 +143,10 @@ describe('vnode', () => {
145143
})
146144

147145
test('function', () => {
148-
const vnode = createVNode('p', null, nop)
149-
expect(vnode.children).toMatchObject({ default: nop })
146+
const vnode = createVNode('p', null, () => 'foo')
147+
expect(vnode.children).toBe('foo')
150148
expect(vnode.shapeFlag).toBe(
151-
ShapeFlags.ELEMENT | ShapeFlags.SLOTS_CHILDREN
149+
ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN
152150
)
153151
})
154152

packages/runtime-core/src/vnode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ export function normalizeChildren(vnode: VNode, children: unknown) {
800800
}
801801
}
802802
} else if (isFunction(children)) {
803-
if (shapeFlag & ShapeFlags.ELEMENT) {
803+
if (shapeFlag & (ShapeFlags.ELEMENT | ShapeFlags.TELEPORT)) {
804804
normalizeChildren(vnode, children())
805805
return
806806
}

0 commit comments

Comments
 (0)