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

chore(find): simplify vnode traversal #835

Merged
merged 1 commit into from
Aug 10, 2021

Conversation

xanf
Copy link
Collaborator

@xanf xanf commented Aug 6, 2021

Basically, this is a proper finisher for #188 - we can avoid going over same vnodes again and again if we do not queue them multiple times - as long as we queue node.component.subTree - no need to queuesubTree.children - they will be aggregated later by calling aggregateChildren(nodes, node.children)

@lmiller1990 I think you will be happy to see we're finally simplifying this part a bit :)

aggregateChildren(nodes, [node.component.subTree])
}
if (node.suspense) {
// match children if component is Suspense
const { activeBranch } = node.suspense
aggregateChildren(nodes, [activeBranch])
}
if (matches(node, selector) && !matchingNodes.includes(node)) {
if (matches(node, selector)) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice

Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Great! I don't like how this is implemented in general - all the mutation is really confusing, I think we should really be using recursion here. Anyway, this is a good place to start simplifying things - we have lots of tests, so if someone does want to rework it for whatever reason, we can do so with confidence.

@lmiller1990 lmiller1990 merged commit fb65416 into vuejs:master Aug 10, 2021
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