Skip to content

fix(unplugin): keep parent nodes with components when removing children - #2991

Merged
posva merged 1 commit into
mainfrom
fix/unplugin-parent-node-delete
Dec 3, 2026
Merged

posva merged 1 commit into
mainfrom
fix/unplugin-parent-node-delete

Conversation

@posva

@posva posva commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Preserved parent route nodes and their components when removing their final child, preventing routes from being removed unexpectedly.

@netlify

netlify Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit 4716435
🔍 Latest deploy log https://app.netlify.com/projects/vue-router/deploys/6b115fc829d7d41ecde9dd68

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The tree now retains a non-root node with components after its final child is deleted. Two tests cover removing the child by file path and deleting the child node directly.

Changes: Parent route retention

Layer / File(s) Summary
Retain component nodes
packages/router/src/unplugin/core/tree.ts, packages/router/src/unplugin/core/tree.spec.ts
deleteChild retains non-root nodes with components. Tests verify that the users node retains its _parent.vue component after either child-removal path.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: frontenddog

Merge Risk: Minimal · up to 47164

Removing the last child route no longer deletes a parent that has its own component. This is a small, localized fix with tests for both removal paths, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: parent nodes that have components are kept when their children are removed. The raw summary says tree.ts stops deleting non-matchable nodes that carry components, and …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: parent nodes that have components are kept when their children are removed. The raw summary says tree.ts stops deleting non-matchable nodes that carry components, and the added tests check that the users node and its _parent.vue component remain after child removal. The title is specific and matches the changeset. The PR objectives state the same aim.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e9bec97 and 4716435.

Files selected for processing: 2

  • packages/router/src/unplugin/core/tree.spec.ts
  • packages/router/src/unplugin/core/tree.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Dec 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/vue-router@2991
npm i https://pkg.pr.new/vue-router@2991
yarn add https://pkg.pr.new/vue-router@2991.tgz

commit: 4716435

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.72%. Comparing base (e9bec97) to head (4716435).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2991   +/-   ##
=======================================
  Coverage   92.72%   92.72%           
=======================================
  Files          84       84           
  Lines        6664     6664           
  Branches     2195     2217   +22     
=======================================
  Hits         6179     6179           
  Misses        440      440           
  Partials       45       45           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@posva
posva added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit 57b2ad6 Dec 3, 2026
13 checks passed
@posva
posva deleted the fix/unplugin-parent-node-delete branch December 3, 2026 12:33
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.

1 participant