Bufix/routing system#32
Merged
Merged
Conversation
…t after leaving a nested route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a router bug where the
Routeoutlet permanently froze after navigating away from a nested route. Navigating from a nested child route (e.g./ui/button) to a top-level route could wedge the outlet on the old layout — every later navigation changed the URL but not the rendered page.Root cause:
Route.updateis async (itawaits lazy component loads) and used anisUpdating/pendingUpdateflag pair plus aroute.path === currentPathinsert guard. The startup sequence (createRoutersets the route to/, then aqueueMicrotasknavigates to the real deep URL) produces overlappingupdate()calls; under that timing raceisUpdatingcould get stucktrue(every later update short-circuited) and stale route content could be inserted. This reproduced reliably in a real browser but not in happy-dom tests, whose microtask timing dodged the race.Fix: Replaced the flag-based concurrency in both
RouteandOutletwith a monotonic per-update sequence ("latest wins") — a load superseded mid-flight is discarded and only the latest navigation commits to the DOM.Outletalso now clears +dispose()s stale child content when leaving the nested area (previously it kept stale content and leaked the child's reactive bindings/listeners on every nested navigation) and skips redundant re-renders of the same child.Bumped
sibujsto3.2.1, updated CHANGELOG, and added regression tests (tests/router.nested-to-top.test.ts): nested→top swap + a rapid-burst "latest wins" case. Full router suite (221 tests) passes; verified end-to-end in the browser (nested→top, top→nested, sidebar nested→nested, rapid-fire bursts, back/forward).Related Issue
Closes #
Type of Change
Checklist