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

fix(find): allow finding stubs by stub definition #1113

Merged
merged 1 commit into from Dec 1, 2021

Conversation

xanf
Copy link
Collaborator

@xanf xanf commented Nov 29, 2021

Long-long ago, in the galaxy far-far away it started pretty simple: we've passed a stub for a component and VTU rendered this stub via transformVNodeArgs provided by Vue core:

Untitled-2021-11-29-1408

We were able to find stub by stub (obviously, because VNode matched) and component by stub because we've tracked relation between component and it's stub (blue line)

Unfortunately, soon we've discovered that sometimes people use same stub for stubbing multiple components:

Untitled-2021-11-29-1408-1

This was a problem, because we were unable to tell, if Stub 1 was the stub of Original component 1 or Original component 2

So, we've introduced a "specialized stub" concept - it is simply a copy of original stub, so for each original component stub is "unique":

Untitled-2021-11-29-1408-2

We were still tracking relation between specialized stubs and original components (red dotted line) to keep everything consistent.

Unfortunately, this broke use case, when people are searching stubs by passing stub as component - if stub has no name, it will not match anything (and it worked in VTU v1). So this PR is pretty simple: it adds tracking relations between specialized stubs and stubs too, so we could match specialized stubs when searching for stubs (green dotted line):

Untitled-2021-11-29-1408-3

Copy link
Member

@cexbrayat cexbrayat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and this PR probably wins the best PR description of the year 😉

@cexbrayat cexbrayat merged commit c6be837 into master Dec 1, 2021
@cexbrayat cexbrayat deleted the xanf-better-stub branch December 1, 2021 07:49
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.

None yet

2 participants