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: assert we do not traverse past the root #4184

Merged
merged 1 commit into from
Apr 30, 2024
Merged

Conversation

nolanlawson
Copy link
Contributor

Details

After implementing #4181, I realized there is one possible case where we could incorrectly generate the static parts, and thus we should add an assertion here as well.

The case is where the root of the static tree is not the ultimate root, and it has a right sibling. In that case, we would incorrectly traverse to the right of the root.

(Note this is impossible today because we generate the static parts correctly in @lwc/template-compiler; this is just an assert to ensure we never make this mistake in the future.)

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.

@nolanlawson nolanlawson requested a review from a team as a code owner April 30, 2024 16:01
// walk up
node = getParentNode(node);
}
// we never want to walk right from the root
assertNotRoot(node);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note I have a similar PR forthcoming for @lwc/synthetic-shadow that demonstrates that it is possible to mistakenly traverse right from the root in this algorithm. But in these tests this case is not possible to hit.

@nolanlawson nolanlawson merged commit 6a1b9b3 into master Apr 30, 2024
10 checks passed
@nolanlawson nolanlawson deleted the nolan/sanity-check branch April 30, 2024 17:32
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