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: modular tree merge #22

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stack-spot/citron-navigator",
"version": "1.3.0",
"version": "1.3.1",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions packages/runtime/src/CitronNavigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ export class CitronNavigator {
})
// copy all the child routes that existed in the old route, but don't exist in the new one (merge):
Object.keys(oldRoute).forEach((key) => {
// @ts-ignore
if (!key.startsWith('$') && !(key in route) && oldRoute[key] instanceof Route) route[key] = oldRoute[key]
if (!key.startsWith('$') && !(key in route) && oldRoute[key] instanceof Route) {
oldRoute[key].$parent = route
route[key as keyof typeof route] = oldRoute[key]
}
})
this.updateRoute()
}
Expand Down
3 changes: 3 additions & 0 deletions packages/runtime/test/CitronNavigator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ describe('Citron Navigator', () => {
expect(root).not.toBeInstanceOf(RootRoute)
expect(root).toBeInstanceOf(AlternativeRootRoute)
expect(root.workspaces).toBeInstanceOf(WorkspacesRoute)
expect(root.workspaces.$parent).toBeInstanceOf(AlternativeRootRoute)
expect(root.account).toBeInstanceOf(AccountRoute)
expect(root.account.$parent).toBeInstanceOf(AlternativeRootRoute)
expect(root.studios).toBeInstanceOf(StudiosRoute)
expect(root.studios.$parent).toBeInstanceOf(AlternativeRootRoute)
})

it("should fail to update navigation tree if anchor doesn't exist", () => {
Expand Down