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

View File

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