Fix routing edge cases and clarify navigation behavior - #570
Merged
Conversation
|
|
size-limit report 馃摝
|
This was referenced Sep 5, 2026
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.
Fix routing edge cases found while reviewing all 27 open issues. Each issue's change has its own commit; existing hash-navigation defaults, URL decoding, and public navigation signatures are preserved.
Changes
Link asChildattributes, styles, active classes, and React refs. Preserve omitted child props and Preact child refs; update both packages' types.Switchupdates. Also reproduces and resolves the overlapping-route case in wouter Switch matches less-specific Route for 1 render when using browser 'back' button聽#464./route?to clear hash-router search parameters./routestill preserves them. This addresses query clearing, not the historical URL-format migration.useRoute("~/...")match against the full location inside nested bases. Relative patterns and regular expressions retain their behavior.aroundNav: browser Back/Forward and low-level navigation bypass it.<ViewTransition>animations.Validation
bun test --coverage: 243 passed, 1 existing skip, 0 failed; 100% line coverage (13 more tests than the baseline).bun run test-types,bun run lint, and the repository build script passed. Local lint reports four pre-existing warnings in ignored generated bundles.The native-history fix was also checked in real Chrome against a failing control. New runtime regressions were demonstrated before their fixes. The parser recipe was executed with its documented dependency API.
Size optimization
Reuse Link's rest-props object, pass children directly to
createElement, simplify the absolute-pattern check, and shorten browser event registration. These retain the new behavior while reducing bundle size. No limits, ignored dependencies, or measurement settings were relaxed.Size-limit results in minified Brotli bytes:
The previous CI comparison reused generated Preact files from the PR when measuring the base branch. The size workflow now regenerates them after each checkout; the table uses independently prepared sources for every revision. The remaining increase pays for the new fixes, particularly grouped history notifications and absolute route matching.
Remaining issues reviewed
base聽#558, Support for URL Pattern API聽#552, Missing navigation history/back functionality聽#539, [feature request] access hash using defaultuseLocationhook聽#517, Feature Request: AddmatchRoutesFunction聽#512, Support relative links聽#511, Handle Browser Back and Forward Buttons with Custom Page Transition聽#470, Support nested Switches聽#467, Feature request: scroll restoration聽#300: New routing/history/parser/scroll behavior or existing extension points; no additional bounded fix identified.Documentation-only and partial fixes above intentionally do not claim to implement the broader requested features.
Fixes #536
Fixes #556
Fixes #244
Refs #464, #473, #452, #559, #563