Skip to content

Commit

Permalink
fix(runtime-utils): pass global directives to renderSuspended
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 3, 2024
1 parent 73b8d7a commit cf1b48f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/app-vitest-full/tests/nuxt/render-suspended.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import App from '~/app.vue'
import OptionsComponent from '~/components/OptionsComponent.vue'
import WrapperTests from '~/components/WrapperTests.vue'
import LinkTests from '~/components/LinkTests.vue'
import DirectiveComponent from '~/components/DirectiveComponent.vue'

import ExportDefaultComponent from '~/components/ExportDefaultComponent.vue'
import ExportDefineComponent from '~/components/ExportDefineComponent.vue'
Expand Down Expand Up @@ -77,6 +78,15 @@ describe('renderSuspended', () => {
)
})

it('respects directives registered in nuxt plugins', async () => {
const component = await renderSuspended(DirectiveComponent)
expect(component.html()).toMatchInlineSnapshot(`
"<div id="test-wrapper">
<div data-directive="true"></div>
</div>"
`)
})

it('can pass slots to rendered components within nuxt suspense', async () => {
const text = 'slot from render suspense'
await renderSuspended(OptionsComponent, {
Expand Down
1 change: 1 addition & 0 deletions src/runtime-utils/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export async function renderSuspended<T>(
config: {
globalProperties: vueApp.config.globalProperties,
},
directives: vueApp._context.directives,
provide: vueApp._context.provides,
components: { RouterLink },
},
Expand Down

0 comments on commit cf1b48f

Please sign in to comment.