Repository navigation
fix: prefer the searched component over one sharing its name in findComponent - #3080
Conversation
👷 Deploy request for vue-test-utils-docs pending review.Visit the deploys page to approve it
|
commit: |
cexbrayat
left a comment
There was a problem hiding this comment.
Could we rank the matching component instances before creating wrappers? If I understand correctly,findAllComponents() creates wrappers for every candidate, which runs wrapper plugins and installs native event listeners even for components that findComponent() won’t return no?
|
Good point, updated: This also applies to the cases that don't involve a same-named component: |
Fixes #3074
As discussed in #3074, this also covers the deeper case left out of #3077.
When a component renders another one with the same name (like a
Button.vuewith<script setup>wrapping a libraryButton),findComponent(LibButton)returns the wrapper instead ofLibButton. On the mounted component this comes from #3063, deeper in the tree it already happens in 2.6.0: playground.findComponentnow prefers a component rendered from the searched definition (or its stub) over one that only matches by name. That check moves out ofmatchesinto amatchesDefinitionhelper.findAllComponentsis unchanged, so when its first result only shares the name,findComponentnow returns a later one.