Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slot drilling error when named slot is missing #787

Closed
Jexordexan opened this issue Feb 27, 2020 · 0 comments
Closed

Slot drilling error when named slot is missing #787

Jexordexan opened this issue Feb 27, 2020 · 0 comments

Comments

@Jexordexan
Copy link

Version

3.0.0-alpha.7

Reproduction link

https://codesandbox.io/s/vue-3-slot-drilling-error-92srn

Steps to reproduce

Open the sandbox and check the console

What is expected?

Missing slots skip rendering.

What is actually happening?

Component throws an error and doesn't render any content

TypeError: Cannot read property 'name' of undefined
    at createSlots (https://unpkg.com/[email protected]/dist/vue.global.js:9054:26)
    at Proxy.render (eval at compileToFunction (https://unpkg.com/[email protected]/dist/vue.global.js:10172:24), <anonymous>:15:44)
    at renderComponentRoot (https://unpkg.com/[email protected]/dist/vue.global.js:5056:55)
    at componentEffect (https://unpkg.com/[email protected]/dist/vue.global.js:6891:55)
    at run (https://unpkg.com/[email protected]/dist/vue.global.js:4060:22)
    at reactiveEffect (https://unpkg.com/[email protected]/dist/vue.global.js:4041:18)
    at effect (https://unpkg.com/[email protected]/dist/vue.global.js:4026:11)
    at setupRenderEffect (https://unpkg.com/[email protected]/dist/vue.global.js:6889:29)
    at mountComponent (https://unpkg.com/[email protected]/dist/vue.global.js:6882:11)
    at processComponent (https://unpkg.com/[email protected]/dist/vue.global.js:6808:19)

I realize this might not be a common use case, but the practice of passing slot content to child components is useful for complex library components.

My use case is porting an autocomplete component from the v2 composition-api plugin to v3. One of the slots on the base component, Autocomplete, is named "suggestion", which, if it exists, is handed to the inner AutocompleteList component. It works fine with the v2 plugin but is broken in v3.

This bug also shows up if the fallback content is set for the named slot, which is strange because I would expect that fallback to create the necessary render function.

Offending Code:
https://github.com/vuejs/vue-next/blob/master/packages/runtime-core/src/helpers/createSlots.ts#L22

@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant