|
@@ -25,6 +25,12 @@ import { DynamicFragment, type VaporFragment } from './fragment'
|
|
|
import { createElement } from './dom/node'
|
|
import { createElement } from './dom/node'
|
|
|
import { setDynamicProps } from './dom/prop'
|
|
import { setDynamicProps } from './dom/prop'
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Flag to indicate if we are executing a once slot.
|
|
|
|
|
+ * When true, renderEffect should skip creating reactive effect.
|
|
|
|
|
+ */
|
|
|
|
|
+export let inOnceSlot = false
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Current slot scopeIds for vdom interop
|
|
* Current slot scopeIds for vdom interop
|
|
|
*/
|
|
*/
|
|
@@ -163,6 +169,7 @@ export function createSlot(
|
|
|
rawProps?: LooseRawProps | null,
|
|
rawProps?: LooseRawProps | null,
|
|
|
fallback?: VaporSlot,
|
|
fallback?: VaporSlot,
|
|
|
noSlotted?: boolean,
|
|
noSlotted?: boolean,
|
|
|
|
|
+ once?: boolean,
|
|
|
): Block {
|
|
): Block {
|
|
|
const _insertionParent = insertionParent
|
|
const _insertionParent = insertionParent
|
|
|
const _insertionAnchor = insertionAnchor
|
|
const _insertionAnchor = insertionAnchor
|
|
@@ -236,9 +243,12 @@ export function createSlot(
|
|
|
const prevSlotScopeIds = setCurrentSlotScopeIds(
|
|
const prevSlotScopeIds = setCurrentSlotScopeIds(
|
|
|
slotScopeIds.length > 0 ? slotScopeIds : null,
|
|
slotScopeIds.length > 0 ? slotScopeIds : null,
|
|
|
)
|
|
)
|
|
|
|
|
+ const prev = inOnceSlot
|
|
|
try {
|
|
try {
|
|
|
|
|
+ if (once) inOnceSlot = true
|
|
|
return slot(slotProps)
|
|
return slot(slotProps)
|
|
|
} finally {
|
|
} finally {
|
|
|
|
|
+ inOnceSlot = prev
|
|
|
setCurrentSlotScopeIds(prevSlotScopeIds)
|
|
setCurrentSlotScopeIds(prevSlotScopeIds)
|
|
|
}
|
|
}
|
|
|
}),
|
|
}),
|
|
@@ -249,7 +259,7 @@ export function createSlot(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// dynamic slot name or has dynamicSlots
|
|
// dynamic slot name or has dynamicSlots
|
|
|
- if (isDynamicName || rawSlots.$) {
|
|
|
|
|
|
|
+ if (!once && (isDynamicName || rawSlots.$)) {
|
|
|
renderEffect(renderSlot)
|
|
renderEffect(renderSlot)
|
|
|
} else {
|
|
} else {
|
|
|
renderSlot()
|
|
renderSlot()
|