Skip to content

Bufix/routing system#32

Merged
hexplus merged 36 commits into
mainfrom
bufix/routing-system
Jun 5, 2026
Merged

Bufix/routing system#32
hexplus merged 36 commits into
mainfrom
bufix/routing-system

Conversation

@hexplus

@hexplus hexplus commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Description

Fixes a router bug where the Route outlet 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.update is async (it awaits lazy component loads) and used an isUpdating/pendingUpdate flag pair plus a route.path === currentPath insert guard. The startup sequence (createRouter sets the route to /, then a queueMicrotask navigates to the real deep URL) produces overlapping update() calls; under that timing race isUpdating could get stuck true (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 Route and Outlet with a monotonic per-update sequence ("latest wins") — a load superseded mid-flight is discarded and only the latest navigation commits to the DOM. Outlet also 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 sibujs to 3.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

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • I have read CONTRIBUTING.md
  • My code builds without errors
  • I have tested my changes
  • I have updated documentation if needed

hexplus added 30 commits March 28, 2026 15:11
@hexplus hexplus merged commit c0c0e8d into main Jun 5, 2026
1 check passed
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