mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-22 11:22:43 +00:00
fix(nuxt): wrap slot with h()
in ClientOnly (#30664)
This commit is contained in:
parent
e5a7c19b18
commit
c5a78ea154
@ -14,7 +14,7 @@ export default defineComponent({
|
|||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
|
||||||
props: ['fallback', 'placeholder', 'placeholderTag', 'fallbackTag'],
|
props: ['fallback', 'placeholder', 'placeholderTag', 'fallbackTag'],
|
||||||
setup (_, { slots, attrs }) {
|
setup (props, { slots, attrs }) {
|
||||||
const mounted = ref(false)
|
const mounted = ref(false)
|
||||||
onMounted(() => { mounted.value = true })
|
onMounted(() => { mounted.value = true })
|
||||||
// Bail out of checking for pages/layouts as they might be included under `<ClientOnly>` 🤷♂️
|
// Bail out of checking for pages/layouts as they might be included under `<ClientOnly>` 🤷♂️
|
||||||
@ -24,10 +24,10 @@ export default defineComponent({
|
|||||||
nuxtApp._isNuxtLayoutUsed = true
|
nuxtApp._isNuxtLayoutUsed = true
|
||||||
}
|
}
|
||||||
provide(clientOnlySymbol, true)
|
provide(clientOnlySymbol, true)
|
||||||
return (props: any) => {
|
return () => {
|
||||||
if (mounted.value) { return slots.default?.() }
|
if (mounted.value) { return slots.default?.() }
|
||||||
const slot = slots.fallback || slots.placeholder
|
const slot = slots.fallback || slots.placeholder
|
||||||
if (slot) { return slot() }
|
if (slot) { return h(slot) }
|
||||||
const fallbackStr = props.fallback || props.placeholder || ''
|
const fallbackStr = props.fallback || props.placeholder || ''
|
||||||
const fallbackTag = props.fallbackTag || props.placeholderTag || 'span'
|
const fallbackTag = props.fallbackTag || props.placeholderTag || 'span'
|
||||||
return createElementBlock(fallbackTag, attrs, fallbackStr)
|
return createElementBlock(fallbackTag, attrs, fallbackStr)
|
||||||
|
Loading…
Reference in New Issue
Block a user