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(get-ancestry): don't error when there is no parent #4617

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

straker
Copy link
Contributor

@straker straker commented Oct 17, 2024

Seems I removed the conditional check on the children lookup during a refactor. Adding it back in and ensuring there's a test so this doesn't happen again.

dbjorge
dbjorge previously approved these changes Oct 17, 2024
@dbjorge dbjorge dismissed their stale review October 17, 2024 20:04

approved too early

@@ -9,7 +9,7 @@ function generateAncestry(node) {
if (
nodeName !== 'head' &&
nodeName !== 'body' &&
parentNode.children.length > 1
parentNode?.children.length > 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't realize that the optional chaining operation short circuited like this; I got worried that this would need to be parentNode?.children?.length, but it turns out this is fine

@straker straker merged commit a005703 into develop Oct 17, 2024
22 checks passed
@straker straker deleted the fix-get-ancestry branch October 17, 2024 21:07
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