Skip to content

Commit 2a8b9c3

Browse files
committed
fix
1 parent afafd83 commit 2a8b9c3

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

packages/runtime-vapor/src/apiCreateComponent.ts

+15-24
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import {
44
createComponentInstance,
55
currentInstance,
66
} from './component'
7-
import { type Block, setupComponent } from './apiRender'
7+
import { setupComponent } from './apiRender'
88
import {
99
type NormalizedRawProps,
1010
type RawProps,
1111
normalizeRawProps,
1212
walkRawProps,
1313
} from './componentProps'
14-
import type { RawSlots } from './componentSlots'
14+
import { type RawSlots, isDynamicSlotFn } from './componentSlots'
1515
import { withAttrs } from './componentAttrs'
1616
import { isString } from '@vue/shared'
1717
import { renderEffect } from './renderEffect'
@@ -24,9 +24,9 @@ export function createComponent(
2424
slots: RawSlots | null = null,
2525
singleRoot: boolean = false,
2626
once: boolean = false,
27-
): ComponentInternalInstance {
27+
): ComponentInternalInstance | HTMLElement {
2828
if (isString(comp)) {
29-
return fallbackComponent(comp, rawProps, slots, singleRoot)
29+
return fallbackComponent(comp, rawProps, slots)
3030
}
3131

3232
const current = currentInstance!
@@ -48,8 +48,7 @@ function fallbackComponent(
4848
comp: string,
4949
rawProps: RawProps | null,
5050
slots: RawSlots | null,
51-
singleRoot: boolean,
52-
) {
51+
): HTMLElement {
5352
// eslint-disable-next-line no-restricted-globals
5453
const el = document.createElement(comp)
5554

@@ -62,24 +61,16 @@ function fallbackComponent(
6261
})
6362
}
6463

65-
if (slots && slots.length) {
66-
renderEffect(() => {
67-
let block: Block | undefined
68-
69-
if (slots && slots.default) {
70-
block = slots.default()
71-
} else {
72-
for (const slotFn of dynamicSlots!) {
73-
const slot = slotFn()
74-
if (slot.name === 'default') {
75-
block = slot.fn()
76-
break
77-
}
78-
}
64+
if (slots) {
65+
if (!Array.isArray(slots)) slots = [slots]
66+
for (let i = 0; i < slots.length; i++) {
67+
const slot = slots[i]
68+
if (!isDynamicSlotFn(slot) && slot.default) {
69+
const block = slot.default && slot.default()
70+
if (block) el.append(...normalizeBlock(block))
7971
}
80-
81-
if (block) el.append(...normalizeBlock(block))
82-
})
72+
}
8373
}
84-
return { __return: el, rawProps }
74+
75+
return el
8576
}

packages/runtime-vapor/src/componentProps.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function registerProp(
163163
}
164164
}
165165

166-
export function normalizeRawProps(rawProps: RawProps) {
166+
export function normalizeRawProps(rawProps: RawProps): NormalizedRawProps {
167167
if (!rawProps) return []
168168
if (!isArray(rawProps)) return [rawProps]
169169
return rawProps
@@ -172,7 +172,7 @@ export function normalizeRawProps(rawProps: RawProps) {
172172
export function walkRawProps(
173173
rawProps: NormalizedRawProps,
174174
cb: (key: string, value: any, getter?: boolean) => void,
175-
) {
175+
): void {
176176
for (const props of Array.from(rawProps).reverse()) {
177177
if (isFunction(props)) {
178178
const resolved = props()

0 commit comments

Comments
 (0)