fix(nuxt): avoid passing attrs to default slot for ClientOnly (#8921)

This commit is contained in:
Julien Huang 2022-11-14 11:27:57 +01:00 committed by GitHub
parent dc22bd3829
commit 8c4ff5c585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -2,9 +2,10 @@ import { ref, onMounted, defineComponent, createElementBlock, h, createElementVN
export default defineComponent({
name: 'ClientOnly',
inheritAttrs: false,
// eslint-disable-next-line vue/require-prop-types
props: ['fallback', 'placeholder', 'placeholderTag', 'fallbackTag'],
setup (_, { slots }) {
setup (_, { slots, attrs }) {
const mounted = ref(false)
onMounted(() => { mounted.value = true })
return (props) => {
@ -13,7 +14,7 @@ export default defineComponent({
if (slot) { return slot() }
const fallbackStr = props.fallback || props.placeholder || ''
const fallbackTag = props.fallbackTag || props.placeholderTag || 'span'
return createElementBlock(fallbackTag, null, fallbackStr)
return createElementBlock(fallbackTag, attrs, fallbackStr)
}
}
})