mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-19 15:10:58 +00:00
fix(nuxt): don't render unknown components with placeholder (#18494)
This commit is contained in:
parent
3ec108493d
commit
fdb31f418f
@ -133,12 +133,14 @@ function findComponent (components: Component[], name: string, mode: LoaderOptio
|
|||||||
const component = components.find(component => id === component.pascalName && ['all', mode, undefined].includes(component.mode))
|
const component = components.find(component => id === component.pascalName && ['all', mode, undefined].includes(component.mode))
|
||||||
if (component) { return component }
|
if (component) { return component }
|
||||||
|
|
||||||
|
const otherModeComponent = components.find(component => id === component.pascalName)
|
||||||
|
|
||||||
// Render client-only components on the server with <ServerPlaceholder> (a simple div)
|
// Render client-only components on the server with <ServerPlaceholder> (a simple div)
|
||||||
if (mode === 'server' && !component) {
|
if (mode === 'server' && otherModeComponent) {
|
||||||
return components.find(c => c.pascalName === 'ServerPlaceholder')
|
return components.find(c => c.pascalName === 'ServerPlaceholder')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the other-mode component in all other cases - we'll handle createClientOnly
|
// Return the other-mode component in all other cases - we'll handle createClientOnly
|
||||||
// and createServerComponent above
|
// and createServerComponent above
|
||||||
return components.find(component => id === component.pascalName)
|
return otherModeComponent
|
||||||
}
|
}
|
||||||
|
1
test/fixtures/basic/pages/index.vue
vendored
1
test/fixtures/basic/pages/index.vue
vendored
@ -16,6 +16,7 @@
|
|||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NestedSugarCounter :multiplier="2" />
|
<NestedSugarCounter :multiplier="2" />
|
||||||
<CustomComponent />
|
<CustomComponent />
|
||||||
|
<Spin>Test</Spin>
|
||||||
<component :is="`test${'-'.toString()}global`" />
|
<component :is="`test${'-'.toString()}global`" />
|
||||||
<component :is="`with${'-'.toString()}suffix`" />
|
<component :is="`with${'-'.toString()}suffix`" />
|
||||||
<ClientWrapped ref="clientRef" style="color: red;" class="client-only" />
|
<ClientWrapped ref="clientRef" style="color: red;" class="client-only" />
|
||||||
|
13
test/fixtures/basic/plugins/register.ts
vendored
Normal file
13
test/fixtures/basic/plugins/register.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { defineComponent, h } from 'vue'
|
||||||
|
|
||||||
|
const Spin = defineComponent({
|
||||||
|
setup (props, { slots }) {
|
||||||
|
return () => {
|
||||||
|
return h('div', slots.default?.())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
|
nuxtApp.vueApp.component('Spin', Spin)
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user