Skip to content

fix: find components by registered name inside slots - #3032

Merged
cexbrayat merged 1 commit into
vuejs:mainfrom
ValentinYoushkevich:fix/find-registered-name-in-slots
Nov 17, 2026
Merged

cexbrayat merged 1 commit into
vuejs:mainfrom
ValentinYoushkevich:fix/find-registered-name-in-slots

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

findComponent({ name }) and findAllComponents({ name }) find a component without a name by the key it is registered or imported under, but not when it is rendered in a slot of another component (or inside <transition>). The default create-vue scaffold hits this: its icons are template-only SFCs passed into the #icon slot of WelcomeItem (playground).

const wrapper = mount(TheWelcome)
wrapper.findComponent(DocumentationIcon).exists() // true
wrapper.findComponent({ name: 'DocumentationIcon' }).exists() // false

The name is looked up in the registry and the script setup bindings of the parent, which for slot content is the component rendering the slot. The fix also looks it up in the component that rendered the vnode (vnode.ctx), as stubs already do. The parent stays as a fallback for slots passed in mounting options.

@netlify

netlify Bot commented Nov 14, 2026

Copy link
Copy Markdown

👷 Deploy request for vue-test-utils-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 161b997

@pkg-pr-new

pkg-pr-new Bot commented Nov 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vue/test-utils@3032

commit: 161b997

@cexbrayat
cexbrayat merged commit 21d0436 into vuejs:main Nov 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants